Mysql find duplicate records

Table: employee12

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
+-------+----------+--------+------------+
| Empid | Empname  | Salary | DOB        |
+-------+----------+--------+------------+
|     1 | Habib    |   2014 | 2004-12-02 |
|     2 | Karan    |   4021 | 2003-04-11 |
|     3 | Samia    |     22 | 2008-02-23 |
|     4 | Hui Ling |     25 | 2008-10-15 |
|     5 | Yumie    |     29 | 1999-01-26 |
|    10 | NULL     | 210000 | 2009-01-12 |
|    10 | jjlkl    |   2222 | 2008-02-13 |
|    10 | hkjkkjl  |   2222 | 2008-02-14 |
+-------+----------+--------+------------+

mysql> SELECT *, count(*) as n
    ->  FROM employee12
    ->  group by empid
    ->  HAVING n>1;

Leave a Reply