Search Postgresql Archives

Re: Select CASE when null ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 14, 2009 at 17:56, Mark Styles <postgres@xxxxxxxxxxxx> 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/

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux