Re: Double query

From: "D'Arcy J(dot)M(dot) Cain" <darcy(at)druid(dot)net>
To: PostgreSQL Admin <postgres(at)productivitymedia(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Double query
Date: 2008-02-06 21:17:10
Message-ID: 20080206161710.0589ab6a.darcy@druid.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, 06 Feb 2008 16:01:09 -0500
PostgreSQL Admin <postgres(at)productivitymedia(dot)com> wrote:
> I want to find any value:
>
> SELECT id FROM schedule WHERE clinic_id = '%s' AND date = '%s'
>
> But I want to make sure the clinic exist first then find if the date
> exist 2nd.

I'm not sure what you mean by "first" and "second" but if you mean that
you want a list of all clinics that match the clinic ID and you want to
know of all of those which ones have the specified date then perhaps
this is what you want.

SELECT id, date = '%s' FROM schedule WHERE clinic_id = '%s';

--
D'Arcy J.M. Cain <darcy(at)druid(dot)net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Hart 2008-02-06 21:36:36 outer join issues
Previous Message johnf 2008-02-06 21:01:35 Information schema permissions