[development] SQL question.

Nicolas Tostin nicolast at logis.com.mx
Fri Feb 3 04:41:47 UTC 2006


> 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
> 

The problem here is that if b.c = 'A', it can't be NULL ;)
So you should use something like this
WHERE NVL(b.c, 'A') = 'A' (oracle Syntax, for MySQL it's IFNULL )


More information about the development mailing list