[UPHPU] discovered ISNULL() for default join values in MySQL
Orson Jones
orson.uphpu at afriskito.net
Tue Feb 23 09:23:50 MST 2010
Wade Preston Shearer wrote:
> On 22 Feb 2010, at 17:18, Joseph Scott wrote:
>
>> On Mon, Feb 22, 2010 at 5:03 PM, Wade Preston Shearer
>> <wadeshearer.lists at me.com> wrote:
>>
>>> I looked coalesce up and don't see how would work in this case. Will you provide an example?
>> You didn't provide a specific query to compare with so hard to say
>> exactly how you would use it in your case.
>
> Sorry; here's an example:
>
> SELECT hans.this, hans.that, ISNULL(frans.the, 'default value') as other
> FROM database_hans hans
> LEFT JOIN database_frans frans
> ON hans.fk=frans.pk
That is pretty easy, replace ISNULL with COALESCE
I also like to use it for preferred names:
SELECT COALESCE(preferred, first) AS name FROM people WHERE...
Orson
(sorry for the dup wps, sent from wrong email first time)
More information about the UPHPU
mailing list