Tutorial :Mysql duplicate row problem


i have a seven column in my mysql table 4 is A B C D if he already have value 1 ,2 ,3 ,4 then if anybody thing to re add him then table not allow this how i can do this


Why don't you simply make a unique key for A, B, C, D

ALTER TABLE <tablename> ADD UNIQUE KEY (A, B, C, D);  


You can set a MySQL field to UNIQUE, but not a combination of fields, as far as I know.

So, first do a simple query to see if the combination A=1, B=2, C=3, D=4 already exists. If not, add it, otherwise prompt the user with an error.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »