Re: select based on multi-column primary keys - Mailing list pgsql-sql

From Bruno Wolff III
Subject Re: select based on multi-column primary keys
Date
Msg-id 20070120014524.GC30390@wolff.to
Whole thread Raw
In response to select based on multi-column primary keys  (mawrya <mawrya@furthernorth.net>)
Responses Re: select based on multi-column primary keys  (Richard Broersma Jr <rabroersma@yahoo.com>)
List pgsql-sql
On Fri, Jan 19, 2007 at 16:44:50 -0800, mawrya <mawrya@furthernorth.net> wrote:
> I have set up a table with a multi-column primary key constraint:
> 
> 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

SELECT * FROM iopoints WHERE systemid=123 AND enclosureid='ab' AND pointid=56

While in theory you could concatenate the columns and test that against a
particular value, you probably don't want to do that. (If you do, use a
functional index.)


pgsql-sql by date:

Previous
From: mawrya
Date:
Subject: select based on multi-column primary keys
Next
From: "codeWarrior"
Date:
Subject: Re: select based on multi-column primary keys