RE: user defined table constraint

2004-10-21 Thread Josh Howe
Howe Cc: [EMAIL PROTECTED] Subject: Re: user defined table constraint You need to use a UNIQUE index: ALTER TABLE ADD UNIQUE user_id_primary (user_id, is_primary); I can't find a specific section about UNIQUE indexes in the mysql docs, but I'm sure it's there and I'm pret

Re: user defined table constraint

2004-10-13 Thread Rhino
ctober 13, 2004 3:45 PM Subject: user defined table constraint Hi all, I have a table with these fields: user_id dept_id is_primary ('Y' or 'N') I want to make sure that there are never two rows in this table with the same user_id and is_primary='Y'. For a

Re: user defined table constraint

2004-10-13 Thread SGreen
That depends, can the user have more than 2 records? as in only 1 "yes" record and 1 "no" record? If that were the case you could create a unique index on (user_id, is_primary). However, I suspect that is not the case. If I remember my M$ $QL correctly, User Constraints are evaluated during INS

user defined table constraint

2004-10-13 Thread Josh Howe
Hi all, I have a table with these fields: user_id dept_id is_primary ('Y' or 'N') I want to make sure that there are never two rows in this table with the same user_id and is_primary='Y'. For any user_id, there can only be one primary record. In MS SQL I would define a user constra