From: | Eus <eus(at)member(dot)fsf(dot)org> |
---|---|
To: | pgsql-general(at)postgresql(dot)org, "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com> |
Subject: | Re: Check for an empty result |
Date: | 2009-02-16 02:15:57 |
Message-ID: | 42371.69281.qm@web37608.mail.mud.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi Andreas!
--- On Fri, 2/13/09, A. Kretschmer <andreas(dot)kretschmer(at)schollglas(dot)com> wrote:
> In response to Eus :
> > Hi Ho!
> >
> > Is there a way to check whether or not a subquery
> returns an empty result set?
>
> You can use EXISTS for that:
>
> -- empty result
> test=*# select * from (select 1 where 1=2) foo;
> ?column?
> ----------
> (0 rows)
That's good that it can be used in FROM phrase too besides WHERE phrase.
> -- check if a result exists
> test=*# select exists(select * from (select 1 where 1=2)
> foo);
> ?column?
> ----------
> f
> (1 row)
>
> test=*# select exists(select * from (select 1 where 1=1)
> foo);
> ?column?
> ----------
> t
> (1 row)
Even in SELECT phrase? That's great!
Thank you for the information.
> Regards, Andreas
> --
> Andreas Kretschmer
> Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr:
> -> Header)
> GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA
> http://wwwkeys.de.pgp.net
Best regards,
Eus (FSF member #4445)
In this digital era, where computing technology is pervasive, your freedom depends on the software controlling those computing devices.
Join free software movement today! It is free as in freedom, not as in free beer!
Join: http://www.fsf.org/jf?referrer=4445
From | Date | Subject | |
---|---|---|---|
Next Message | Tino Wildenhain | 2009-02-16 07:10:27 | Re: Running untrusted sql safely? |
Previous Message | Eus | 2009-02-16 02:08:23 | Re: Check for an empty result |