From: Raymond O'Donnell <rod@iol.ie>
To: Killian Driscoll <killiandriscoll@gmail.com>
To: PostgreSQLPHP <pgsql-php@postgresql.org>
Subject: Re: How to limit dropdown list to options based on 'in use' rows from lookup table, for webpage using php and postgresql
Date: Tue, 29 Dec 2015 18:17:55 +0000
Message-ID: <5682CE53.1030409@iol.ie> (raw)
In-Reply-To: <CAL64pZNrh3e8sVrm6MKbz8_4TrRgi7F532JiKLySp0=44YfecA@mail.gmail.com>
References: <CAL64pZNGxLQZ=haCh4Fu0H49VtjGPH8g7ced5Te4gorB1j7ciA@mail.gmail.com>
<5682B63E.9030008@iol.ie>
<CAL64pZOJZ+1=bzz8gtqAbxngYuFuJs+gJpeuBuuUrC61SeRGyw@mail.gmail.com>
<5682BBF3.1020605@iol.ie>
<CAL64pZOJJR2jEa3gLdS+7k3vJPStpsN5qd7pgmz=pM9=h0+wZw@mail.gmail.com>
<5682C041.40706@iol.ie>
<CAL64pZNrh3e8sVrm6MKbz8_4TrRgi7F532JiKLySp0=44YfecA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-php>
On 29/12/2015 17:24, Killian Driscoll wrote:
> So it should be:
> exists select [whatever]
> from country_table ct
> inner join lookup_table lt on (ct.country_type_id = lt.country_type_id)
> [etc]
>
> [whatever] [etc] - what are these?
Apologies - [whatever] stood for whatever columns you might want to
return from the query, for example:
select country_id, col2, col3, [...] from ....
In the case of the subquery inside EXISTS, however, it doesn't matter
what you return - all EXISTS tests is whether or not any rows are
returned. In this instance, it's common simply to write
select 1 from ....
The [etc] stood for any clauses that might follow the WHERE clause, such
as ORDER BY. You don't need ORDER BY in the EXISTS test, as again all
you're checking is whether or not any rows are returned - it doesn't
matter what order their in.
So, short version, what you probably need is just:
exists select 1 from country_table ct
inner join lookup_table lt on (ct.country_type_id = lt.country_type_id)
Hope this helps,
Ray.
--
Raymond O'Donnell :: Galway :: Ireland
rod@iol.ie
--
Sent via pgsql-php mailing list (pgsql-php@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-php
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-php@postgresql.org
Cc: rod@iol.ie, killiandriscoll@gmail.com
Subject: Re: How to limit dropdown list to options based on 'in use' rows from lookup table, for webpage using php and postgresql
In-Reply-To: <5682CE53.1030409@iol.ie>
References: <CAL64pZNGxLQZ=haCh4Fu0H49VtjGPH8g7ced5Te4gorB1j7ciA@mail.gmail.com> <5682B63E.9030008@iol.ie> <CAL64pZOJZ+1=bzz8gtqAbxngYuFuJs+gJpeuBuuUrC61SeRGyw@mail.gmail.com> <5682BBF3.1020605@iol.ie> <CAL64pZOJJR2jEa3gLdS+7k3vJPStpsN5qd7pgmz=pM9=h0+wZw@mail.gmail.com> <5682C041.40706@iol.ie> <CAL64pZNrh3e8sVrm6MKbz8_4TrRgi7F532JiKLySp0=44YfecA@mail.gmail.com> <5682CE53.1030409@iol.ie>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox