Im trying to combine 3 IN statements with ANd in a search im working on. Here is and example that doesnt fully works as i need it to be
SELECT name,thumbnail
FROM table1 WHERE
id IN (SELECT imgid FROM categories WHERE category = 22 )
AND id IN (SELECT imgid FROM namesearch WHERE name LIKE "%car%" )
OR id IN (SELECT imgid FROM tags WHERE tag LIKE "%jet%" )
The above example logically it is in a group like this if im not wrong
(categorie=22 AND tags=car) OR (namesearch=jet)
And if i search jet
that is found at tag
it doesnt filter category=22
How can i group the statements in a logic like this
(categorie=22) AND (tags=car OR|AND namesearch=jet)
It filters category if i put an AND like this
SELECT name,thumbnail
FROM table1 WHERE
id IN (SELECT imgid FROM categories WHERE category = 22 )
AND id IN (SELECT imgid FROM namesearch WHERE name LIKE "%car%" )
AND id IN (SELECT imgid FROM tags WHERE tag LIKE "%jet%" )
But will it search in namesearch or tags or at both in the same time?
Because i dont want to miss tag search if a namesearch is found, i need them both, but namesearch is in high priority.