From: | mawrya <mawrya(at)furthernorth(dot)net> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | select based on multi-column primary keys |
Date: | 2007-01-20 00:44:50 |
Message-ID: | 45B16602.2080508@furthernorth.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Bruno Wolff III | 2007-01-20 01:45:24 | Re: select based on multi-column primary keys |
Previous Message | Andrew Sullivan | 2007-01-19 19:15:45 | Re: Permissions Query? |