Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id E4E292E3C63 for ; Wed, 6 Feb 2008 17:01:24 -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 09106-03 for ; Wed, 6 Feb 2008 17:01:17 -0400 (AST) Received: from ns2.instrumentalyst.com (blk-222-55-203.eastlink.ca [24.222.55.203]) by postgresql.org (Postfix) with ESMTP id 82EE12E408F for ; Wed, 6 Feb 2008 17:01:21 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by ns2.instrumentalyst.com (Postfix) with ESMTP id 0848A434 for ; Wed, 6 Feb 2008 16:54:48 -0400 (AST) X-Virus-Scanned: amavisd-new at instrumentalyst.com Received: from ns2.instrumentalyst.com ([127.0.0.1]) by localhost (ns2.instrumentalyst.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gzK4buxZluBN for ; Wed, 6 Feb 2008 16:54:40 -0400 (AST) Received: from Arjuna.local (rrcs-24-129-176-158.se.biz.rr.com [24.129.176.158]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ns2.instrumentalyst.com (Postfix) with ESMTP id 9D91F436 for ; Wed, 6 Feb 2008 16:54:40 -0400 (AST) Message-ID: <47AA2015.2060506@productivitymedia.com> Date: Wed, 06 Feb 2008 16:01:09 -0500 From: PostgreSQL Admin User-Agent: Thunderbird 2.0.0.6 (Macintosh/20070728) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Double query References: <20080130104226.GF26490@a-kretschmer.de> <87tzkvbfr6.fsf@oxford.xeocode.com> In-Reply-To: <87tzkvbfr6.fsf@oxford.xeocode.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.579 tagged_above=0 required=5 tests=AWL=0.578, BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 200802/36 X-Sequence-Number: 30127 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