Search Postgresql Archives

Re: How to get CASE statement to recognize null ?

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

 



David Gauthier <davegauthierpg@xxxxxxxxx> writes:
>     dvdb=# select
>       CASE col1
>         WHEN null THEN 'z'
>         ELSE col1
>        END as col1,
>        col2
>      from foo;

This test is equivalent to "col1 = null" which will always fail.
You could try something like

	CASE WHEN col1 IS NULL THEN ... ELSE ... END

Although I think the particular thing you're doing here would
be better solved with COALESCE(col1, 'z').

			regards, tom lane





[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 Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux