Re: Providing an alternative result when there is no result

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Joshua Berry <yoberi(at)gmail(dot)com>, Postgresql General Mailing list <pgsql-general(at)postgresql(dot)org>
Subject: Re: Providing an alternative result when there is no result
Date: 2009-05-20 11:46:24
Message-ID: b42b73150905200446j5b0a55d6n7bd4ed3b5e93f492@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, May 19, 2009 at 7:00 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Merlin Moncure <mmoncure(at)gmail(dot)com> writes:
>> On Mon, May 18, 2009 at 3:13 PM, Joshua Berry <yoberi(at)gmail(dot)com> wrote:
>>> Is there an easy and efficient way to return a boolean false for a query
>>> that returns no result, and true for one that does return a result?
>
>> Probably the best general approach is to:
>
>> select count(*) = 1 from
>> (
>>   <query> limit 1
>> )q;
>
> Seems like EXISTS() is much more straightforward ...

yes...I didn't notice david's response upthread. that is indeed very elegant.

merlin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2009-05-20 11:51:58 Re: Get block of N numbers from sequence
Previous Message Dave Page 2009-05-20 11:46:02 Re: [Windows] Feedback on PG?