3 Feb
2006
3 Feb
'06
3:53 p.m.
On 2/2/06, Gordon Heydon <gordon@heydon.com.au> wrote:
SELECT a.a, a.b, b.a, b.c FROM a LEFT JOIN b ON a.a = b.a WHERE b.c = 'A';
Another way to write this is: SELECT a.a, a.b, b.a, b.c FROM a LEFT JOIN b ON a.a = b.a and 'A' = b.c; Basically you put the condition into the left outer join so that when the values are present, it qualifies them on "='A'" but if there are none it will just show an empty row as you expect from the left outer join. I'm not sure if that syntax works in postgresql or mysql as I didn't test it, but I have some certainty about other sql engines. Regards, Greg