Opposite of Distinct in MySQL

后端 未结 3 1954
无人及你
无人及你 2021-02-05 02:40

I would like to know if there is an opposite of \"select distinct\" in sql ,so that i can use to get values from a table of only which has repeated multiple times.

Thank

3条回答
  •  别那么骄傲
    2021-02-05 03:25

    select some_column, count(*)
    from some_table
    group by 1
    having count(*) > 1;
    

    On databases like mysql, you may even omit selecting count(*) to leave just the column values:

    select some_column
    from some_table
    group by 1
    having count(*) > 1;
    

提交回复
热议问题