I am trying to find rows if the second query that do not exist in the first. But I get the 'You have error in your SQL syntax near a right join' error.
(SELECT t1.id AS id, t2.id, t3.id
FROM table1 t1
INNER JOIN table2 t2 ON t2.id = t1.id
INNER JOIN table3 t3 ON t3.id = t2.id
) a
RIGHT JOIN
(SELECT id
FROM table4
WHERE col1 IS NOT NULL AND col2 IN (1, 2)) b
ON a.id = b.id
What do I do wrong in this query? Thank you.