Re: Need efficient way to do comparison with NULL as an option

From: Lew <lew(at)lwsc(dot)ehost-services(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Need efficient way to do comparison with NULL as an option
Date: 2008-01-05 15:51:57
Message-ID: wK6dnSHN9r8AOuLanZ2dnUVZ_gqdnZ2d@comcast.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

D. Dante Lorenso wrote:
>> But if I want to find all the items which are not in any folder, I want:
>>
>> SELECT *
>> FROM mytable
>> WHERE folder_id IS NULL;
>>
>> I don't have any folder_id 0, so on a URL I might do this:
>>
>> http://xyz/page.php?fid=123
>> http://xyz/page.php?fid=0

SELECT * FROM mytable WHERE COALESCE( folder_id, 0 ) = 0;

--
Lew

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2008-01-05 17:42:11 Re: Performance problem. Could it be related to 8.3-beta4?
Previous Message Cesar Alvarez 2008-01-05 15:07:14 Insert returning Npgsql