Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id EA66F9FB4B8 for ; Fri, 19 Jan 2007 21:11:39 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 16607-01 for ; Fri, 19 Jan 2007 21:11:36 -0400 (AST) X-Greylist: delayed 00:26:39.254863 by SQLgrey-1.7.4 Received: from outbound-mail-69.bluehost.com (unknown [69.89.21.29]) by postgresql.org (Postfix) with SMTP id 66C2E9FB324 for ; Fri, 19 Jan 2007 21:11:36 -0400 (AST) Received: (qmail 10311 invoked by uid 0); 20 Jan 2007 00:44:55 -0000 Received: from unknown (HELO box113.bluehost.com) (70.103.189.155) by mailproxy4.bluehost.com with SMTP; 20 Jan 2007 00:44:55 -0000 Received: from [70.69.160.232] (helo=[192.168.192.28]) by box113.bluehost.com with esmtpa (Exim 4.63) (envelope-from ) id 1H84Lm-0001o7-VF for pgsql-sql@postgresql.org; Fri, 19 Jan 2007 17:44:55 -0700 Message-ID: <45B16602.2080508@furthernorth.net> Date: Fri, 19 Jan 2007 16:44:50 -0800 From: mawrya User-Agent: Thunderbird 1.5.0.9 (Windows/20061207) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: select based on multi-column primary keys Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Identified-User: {971:box113.bluehost.com:furthern:furthernorth.net} {sentby:smtp auth 70.69.160.232 authed with mawrya@furthernorth.net} X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200701/86 X-Sequence-Number: 27238 I have set up a table with a multi-column primary key constraint: CREATE TABLE iopoints ( enclosureid numeric(3) NOT NULL, pointid char(4) NOT NULL, equipmentgroup varchar(64) NOT NULL, deviceid varchar(8), devicetype varchar(24), operationdesc varchar(64) NOT NULL, entrytime timestamp NOT NULL DEFAULT ('now'::text)::timestamp(6) with time zone, systemid numeric(3) NOT NULL, CONSTRAINT "ID" PRIMARY KEY (systemid, enclosureid, pointid) ) WITHOUT OIDS; If I had a row in the table where systemid=123, enclosureid=ab, pointid=56, I would have a Primary Key ("ID") of 123ab56 for that row. I now want to run a select based on the Primary Key, something like: SELECT * FROM iopoints WHERE ID = 123ab56 Is something like this even possible? Or am I forced to do: SELECT * FROM iopoints WHERE systemid=123 AND enclosureid=ab AND pointid=56 I have searched high and low but can not find a syntax example of how to select based on a multi-column primary key, any tips? Thanks, mawrya