Search Postgresql Archives

Re: Select CASE when null ?

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

 



"Camilo Sperberg" <unreal4u@xxxxxxxxxxxxxxxxx> writes:
> SELECT
>   CASE mid WHEN NULL THEN CAST(0 AS integer)
>            ELSE mid
>   END AS mid,

BTW, the reason this doesn't work is the same reason "mid = NULL"
doesn't work, because that's exactly what the CASE condition is
treated as.  The COALESCE trick is certainly the best solution
for this specific need, but the more general way would be

	CASE WHEN mid IS NULL THEN ... ELSE ...

			regards, tom lane

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[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