Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 8A5662E3879 for ; Wed, 6 Feb 2008 17:17:21 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 54443-08 for ; Wed, 6 Feb 2008 17:17:12 -0400 (AST) Received: from smaug.vex.net (smaug.vex.net [208.76.104.132]) by postgresql.org (Postfix) with ESMTP id CEDD92E36AA for ; Wed, 6 Feb 2008 17:17:16 -0400 (AST) Received: from dilbert (dilbert.druid.net [207.35.13.14]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smaug.vex.net (Postfix) with ESMTP id A967D17413; Wed, 6 Feb 2008 16:17:12 -0500 (EST) Date: Wed, 6 Feb 2008 16:17:10 -0500 From: "D'Arcy J.M. Cain" To: PostgreSQL Admin Cc: pgsql-sql@postgresql.org Subject: Re: Double query Message-Id: <20080206161710.0589ab6a.darcy@druid.net> In-Reply-To: <47AA2015.2060506@productivitymedia.com> References: <20080130104226.GF26490@a-kretschmer.de> <87tzkvbfr6.fsf@oxford.xeocode.com> <47AA2015.2060506@productivitymedia.com> X-Mailer: Sylpheed 2.4.7 (GTK+ 2.12.3; x86_64--netbsd) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200802/38 X-Sequence-Number: 30129 On Wed, 06 Feb 2008 16:01:09 -0500 PostgreSQL Admin 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 | 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.