How to find duplicates in 2 columns not 1

后端 未结 6 873
别跟我提以往
别跟我提以往 2020-12-04 05:59

I have a MySQL database table with two columns that interest me. Individually they can each have duplicates, but they should never have a duplicate of BOTH of them having th

6条回答
  •  甜味超标
    2020-12-04 06:58

    To find the duplicates:

    select stone_id, upcharge_title from tablename group by stone_id, upcharge_title having count(*)>1
    

    To constrain to avoid this in future, create a composite unique key on these two fields.

提交回复
热议问题