Excuse me for top-posting but Outlook Express won't put revision bars in
front of your original remarks and I'm too lazy to type them all in myself
;-)
Anyway, if you define one of your columns, such as user_id as a primary key,
you can be sure that there will never be two rows with the same user_id
value, let alone the same user_id value and is_primary value. Wouldn't that
solve your problem without the need for a table constraint?
Rhino
----- Original Message -----
From: "Josh Howe" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, October 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 any user_id, there can only be one
primary record. In MS SQL I would define a user constraint on the table.
Does MySQL have anything similar, or do I need to check the data in
every place I do an insert into this table? Thanks.
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]