mysql - Best way to check for duplicated records -


i have 2 tables a , b relationship of one-to-many a b.

a has 5 columns:

a1, a2, a3, a4, a5  

and b has 5 columns

b1, b2, b3, b4, a1.  

note a1 foreign key in table b.

i have requirement check duplicate records in table i.e. no 2 records should have same values attributes.

the efficient way can think of determining uniqueness creating checksum sort of value , keep in every row of table a. requires space plus have make sure checksum unique.

is best way go ahead or there other way unaware of?

for e.g. lets table a rules table , table b trigger table. rules table has records of various rules created different users.(this means there mapping users table in rules table.). want user should not able create identical rules. when user saves rules run query check if there record of identical checksum particular user if yes give appropriate error otherwise let user create record.i guess clears why can't put unique constraint on records.

do select group clause. example:

select a1, a2, a3, a4, a5, count(*) #temppersons group a1, a2, a3, a4, a5 having count(*) > 1; 

this return result a1, a2, a3, a4, a5 , count of how many times value appears


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -