[development] SQL question.
Earl Miles
merlin at logrus.com
Fri Feb 3 05:14:29 UTC 2006
Gordon Heydon wrote:
> Hi,
>
> I have been trying to work out a small sql issue, and I was wondering if
> someone might be able to help me.
>
> Basically I have 2 tables and I was to do a left join and pull out all
> rows which has a value in the right hand table or doesn't exist.
>
> eg.
>
> SELECT a.a, a.b, b.a, b.c FROM a LEFT JOIN b ON a.a = b.a WHERE b.c =
> 'A';
>
> So basically I want it to return.
>
> a b a c
> 1 1 null null
> 2 2 2 A
>
> etc.
>
> Or do I need to 2 selects and merge them. When I do this now I get more
> of an inner join instead of a left join. I am not sure how I say "or
> doesn't exist".
>
> Thanks in advance.
> Gordon.
...WHERE b.c = 'A' OR b.c IS NULL;
More information about the development
mailing list