How to make a DB query?

There are 2 tables - images_category and images_to_category.
SELECT * FROM images_category JOIN images_to_category ON images_category.id = images_to_category.id_category

There are still images_to_category.id_file the information I needed to know.
SELECT * FROM images_category JOIN images_to_category ON images_category.id = images_to_category.WHERE id_category images_to_category.id_file = 15

Perfectly displays the category in which this file is, but how to make so that it worked in the opposite direction? To remove the opposite category in which this file not at all?
June 7th 19 at 14:25
2 answers
June 7th 19 at 14:27
Solution
Something like this?
SELECT * 
FROM `images_category`
WHERE `id` NOT IN (
 SELECT `images_category`.`id` 
 FROM `images_category` 
 JOIN `images_to_category` ON (`images_category`.`id` = `images_to_category`.`id_category`) 
 WHERE `images_to_category`.`id_file` = 15 )
Thank you so much, the whole evening was perverted with it.
Your method worked, I will disassemble next. - nikita.Stracke commented on June 7th 19 at 14:30
June 7th 19 at 14:29
If I correctly understood the task, something like
SELECT *
FROM images_category
Left Join images_to_category
ON images_category.id = images_to_category.id_category
AND images_to_category.id_file = 15
WHERE images_to_category.id_category is null

Find more questions by tags MySQLSQL