How to find duplicates in 2 columns not 1

后端 未结 6 877
别跟我提以往
别跟我提以往 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:50

    You should set up a composite key between the two fields. This will require a unique stone_id and upcharge_title for each row.

    As far as finding the existing duplicates try this:

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

提交回复
热议问题