I have the following tables:
Topic Content_Topic Content
id_topic topic id_content id_topic id_content content
1 aaaaa 1 2 1 xxxxx
2 bbbbb 1 4 2 yyyyy
3 ccccc 1 5 3 zzzzz
4 ddddd 2 1 4 wwwww
5 eeeee 2 3 5 kkkkk
6 fffff 2 5 6 jjjjj
... 3 3 ...
3 4
3 5
...
I'm trying to run the following query but I'm not obtaining what I expect:
SELECT content FROM Content_Topic ct
LEFT JOIN Content c ON ct.id_content=c.id_topic
LEFT JOIN Topic t ON ct.id_topic=t.id_topic
WHERE (ct.id_topic=2 OR ct.id_topic=3) AND
ct.id_topic IN (4,7,10) AND
(ct.id_topic=5 OR ct.id_topic=9)
What I expect is to have all content that have id_topic 2,4,5 or 3,4,5 or 2,7,5 or 3,7,5 and so on... I receive instead a void result.
What i'm doing wrong?