pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedDouble query
2+ messages / 2 participants
[nested] [flat]
* Double query
@ 2008-02-06 21:01 PostgreSQL Admin <postgres@productivitymedia.com>
0 siblings, 1 reply; 2+ messages in thread
From: PostgreSQL Admin @ 2008-02-06 21:01 UTC (permalink / raw)
To: pgsql-sql
Simple question - but my brain is not working:
This is my table
Column | Type |
Modifiers
-----------+------------------------+-----------------------------------------------------------------
id | integer | not null default
nextval('emr_clinicschedule_id_seq'::regclass)
clinic_id | integer | not null
date | date |
day | smallint |
status | boolean | not null
open | time without time zone |
close | time without time zone |
reason | character varying(64) |
active | boolean | not null
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.
How do I do that?
Thanks in advance,
J
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Double query
@ 2008-02-06 21:17 D'Arcy J.M. Cain <darcy@druid.net>
parent: PostgreSQL Admin <postgres@productivitymedia.com>
0 siblings, 0 replies; 2+ messages in thread
From: D'Arcy J.M. Cain @ 2008-02-06 21:17 UTC (permalink / raw)
To: PostgreSQL Admin <postgres@productivitymedia.com>; +Cc: 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.
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2008-02-06 21:17 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2008-02-06 21:01 Double query PostgreSQL Admin <postgres@productivitymedia.com>
2008-02-06 21:17 ` D'Arcy J.M. Cain <darcy@druid.net>
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