Re: select based on multi-column primary keys

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: mawrya <mawrya(at)furthernorth(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: select based on multi-column primary keys
Date: 2007-01-20 01:45:24
Message-ID: 20070120014524.GC30390@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Fri, Jan 19, 2007 at 16:44:50 -0800,
mawrya <mawrya(at)furthernorth(dot)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.)

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message codeWarrior 2007-01-20 03:45:40 Re: select based on multi-column primary keys
Previous Message mawrya 2007-01-20 00:44:50 select based on multi-column primary keys