When there is a column that is the I have like this: I am using MySQL and MyIsam type tables. I can and Here is the demo. primary key , and that
auto increment .
primary ID on
ID (primary key auto increment), and
userId and
LMCL No preference.
id | UserId | LMCOL -------------------- 1 | 1 | Allow 1/2. 1 | Allow 2/3 1 | Allow 3/4 1 | 1 // If it is re-inserted then it is not allowed I have placed it here for just 5 example 2. Allow 1/6. 2 | Allow 2/7 2 | 3 / Allow 8 2 | 1 // If it is inserted then it is not allowed I have put it here for example
insert
INSERT IGNORE To work in your case, you need to create a unique index on
(userId, elmCol) .
ALTER TABLE table_name ADD CONSTRAINT U_userId_elmCol unique (UIIID, LMCOL);
No comments:
Post a Comment