Hi,
I’ve got the following update query:
UPDATE comunications,
files
INNER JOIN user_join
ON user_join.file_id = files.file_id
SET files.file_status = 1,
comunications.post_status = 1
WHERE comunications.post_id = 18
AND user_join.post_id = comunications.post_id
This is my join table:
The query works fine to update the file in the files table if file_id is not null, but not when file_id is null so, how can adapt this query to update the value in the files table only if file_id is not null? This is what I’ve tried so far:
UPDATE comunications,
files
INNER JOIN user_join
ON user_join.file_id = files.file_id
SET files.file_status = IF(user_join.file_id IS NOT NULL, 1, files.file_status),
comunications.post_status = 1
WHERE comunications.post_id = 18
AND user_join.post_id = comunications.post_id