Re: Select CASE when null ?

From: "Camilo Sperberg" <unreal4u(at)chw(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Select CASE when null ?
Date: 2009-01-14 21:23:10
Message-ID: f05190a90901141323v13d4df29sf12322dd0d9aa481@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Jan 14, 2009 at 17:56, Mark Styles <postgres(at)lambic(dot)co(dot)uk> wrote:

>
> SELECT COALESCE(mid,0) AS mid, COALESCE(id_group,0) AS id_group
> FROM users
> WHERE username = 'test'
> UNION
> SELECT 0, 0
> WHERE NOT EXISTS (SELECT 1 FROM users WHERE username = 'test');
>
>
> --
> Mark
> http://www.lambic.co.uk
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
>
> iD8DBQFJblF5YAVdOy4CIaIRArhBAKCLS3N+ccaigBiZKuJDOebrmbdlSwCghkYf
> zFX5ktrUMPWB9BV9mg5thKo=
> =g/1b
> -----END PGP SIGNATURE-----
>
>
wow amazing :D that did the trick !!!! :D

I had tried COALESCE but I had not thought at all in an union...

Thanks a lot Mark for your incredible fast and fantastic response !

Greetings ;)

--
Mailed by:
UnReAl4U - unreal4u
ICQ #: 54472056
www: http://www.chw.net/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2009-01-14 21:33:04 Re: Select CASE when null ?
Previous Message Mark Styles 2009-01-14 20:59:32 Re: Select CASE when null ?