From: Bruno Wolff III <bruno@wolff.to>
To: mawrya <mawrya@furthernorth.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: select based on multi-column primary keys
Date: Fri, 19 Jan 2007 19:45:24 -0600
Message-ID: <20070120014524.GC30390@wolff.to> (raw)
In-Reply-To: <45B16602.2080508@furthernorth.net>
References: <45B16602.2080508@furthernorth.net>
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.)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: bruno@wolff.to, mawrya@furthernorth.net
Subject: Re: select based on multi-column primary keys
In-Reply-To: <20070120014524.GC30390@wolff.to>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox