Re: [SQL] select based on multi-column primary keys

2007-01-23 Thread Andrew Sullivan
On Tue, Jan 23, 2007 at 01:07:19PM -0800, codeWarrior wrote: > No... its a table constraint using a unique, implicit index on the listed > columns. . Sure. But since these get added as table constraints after dump anyway, I'm not sure I see why it makes a difference. In any case, the point is

Re: [SQL] select based on multi-column primary keys

2007-01-23 Thread codeWarrior
No... its a table constraint using a unique, implicit index on the listed columns. . PRIMARY KEY ( column [, ...] ) The PRIMARY KEY table constraint is similar to the PRIMARY KEY column constraint. As a table constraint, PRIMARY KEY allows multiple columns to be defined in a parenthetical exp

Re: [SQL] select based on multi-column primary keys

2007-01-21 Thread Andrew Sullivan
On Fri, Jan 19, 2007 at 07:45:40PM -0800, codeWarrior wrote: > AFAIK: You cannot have multiple primary keys. How would you know which one > is the actual key ? You can have a multi-column primary key, though. That's a perfectly legitimate approach. > FYI: What you are really talking about are t

Re: [SQL] select based on multi-column primary keys

2007-01-19 Thread Richard Broersma Jr
> SELECT * FROM iopoints WHERE systemid=123 AND enclosureid='ab' AND pointid=56 A slight variation of the syntax would be: select * from iopoints where (systemid, enclosureid, pointid) = (123,'ab',56); this table and fields sounds alot like a control system be being modeled. :-) Regards, Richa

Re: [SQL] select based on multi-column primary keys

2007-01-19 Thread codeWarrior
-- AFAIK: You cannot have multiple primary keys. How would you know which one is the actual key ? FYI: What you are really talking about are table contraints... When you have multiple unique column constraints -- they are generally referred to as "table constraints" not multiple primary keys

Re: [SQL] select based on multi-column primary keys

2007-01-19 Thread Bruno Wolff III
On Fri, Jan 19, 2007 at 16:44:50 -0800, mawrya <[EMAIL PROTECTED]> 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 w

[SQL] select based on multi-column primary keys

2007-01-19 Thread mawrya
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