From: | "Josh Berkus" <josh(at)agliodbs(dot)com> |
---|---|
To: | Francisco Reyes <lists(at)natserv(dot)com> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: If function available? |
Date: | 2001-11-20 16:35:42 |
Message-ID: | web-510100@davinci.ethosmedia.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Francisco,
> I tried it from the psql prompt and didn't work. Is there an IF or
> IIF function that can be used on a select query?
You want CASE, as in:
CASE WHEN field1 = 1 THEN NULL ELSE field1 END
See Postgresql.org --> Documentation --> SQL Commands --> SELECT for
more information, or consult your favorite SQL92 manual.
There are also several special functions for dealing with NULL output,
such as:
COALESCE(x,y,z) : returns first non-null value
NULLIF(x, y) : returns NULL if x = y
-Josh
______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology josh(at)agliodbs(dot)com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco
From | Date | Subject | |
---|---|---|---|
Next Message | Josh Berkus | 2001-11-20 16:41:40 | Re: Emergency backup question. |
Previous Message | Tom Lane | 2001-11-20 15:21:04 | Re: Emergency backup question. |