Re: Double query - Mailing list pgsql-sql

From D'Arcy J.M. Cain
Subject Re: Double query
Date
Msg-id 20080206161710.0589ab6a.darcy@druid.net
Whole thread Raw
In response to Double query  (PostgreSQL Admin <postgres@productivitymedia.com>)
List pgsql-sql
On Wed, 06 Feb 2008 16:01:09 -0500
PostgreSQL Admin <postgres@productivitymedia.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@druid.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.


pgsql-sql by date:

Previous
From: johnf
Date:
Subject: Information schema permissions
Next
From: Tom Hart
Date:
Subject: outer join issues