I'm using the following SQL and was wondering how and where I can put a where clause. So that I can for example bring all the results where id=2?
SELECT *
FROM public_tips
LEFT OUTER JOIN likes
USING (id)
UNION
SELECT *
FROM likes
RIGHT OUTER JOIN public_tips
USING (id)
I have tried
SELECT *
FROM public_tips WHERE id=2
LEFT OUTER JOIN likes
USING (id)
UNION
SELECT *
FROM likes WHERE id=2
RIGHT OUTER JOIN public_tips
USING (id)
but I get a syntax error!
The
where
clause goes after thefrom
clause, and thejoin
clauses are part of thefrom
clause: