| From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> | 
|---|---|
| To: | Joshua Berry <yoberi(at)gmail(dot)com> | 
| Cc: | Postgresql General Mailing list <pgsql-general(at)postgresql(dot)org> | 
| Subject: | Re: Providing an alternative result when there is no result | 
| Date: | 2009-05-18 19:36:56 | 
| Message-ID: | 20090518193656.GD7741@svana.org | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general | 
On Mon, May 18, 2009 at 03:13:56PM -0400, Joshua Berry wrote:
> Hello all,
>
> 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?
>
> Currently we select the result into a temp table.
>
> SELECT INTO temp_table id FROM ... ;
What might work is:
SELECT EXISTS(subquery);
As in:
SELECT EXISTS( SELECT 1 WHERE true );
Have a nice day,
-- 
Martijn van Oosterhout   <kleptog(at)svana(dot)org>   http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while 
> boarding. Thank you for flying nlogn airlines.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David Wilson | 2009-05-18 19:38:11 | Re: Providing an alternative result when there is no result | 
| Previous Message | Reece Hart | 2009-05-18 19:33:15 | Re: Providing an alternative result when there is no result |