I have a mysql table like this:
id employee_number name
1 1 A
2 2 B
3 3 C
4 3 C
5 4 D
6 5 E
7 5 E
8 6 F
9 7 G
8 8 H
9 9 I
10 ....
11 ....
12 ....
many duplicated
employee_number
I want to remove 1 row of employee_number 3 and 5(id 3 or 4 and 6 or 7 don’t matter).
I can see the duplicated rows with the following sql but not sure what to do next. I apprciate if someone can help me out on this one. Thanks a lot!
SELECT COUNT( id ) , employee_number
FROM `employees`
GROUP BY employee_number
Updated:
CREATE TABLE new_table as
SELECT * FROM old_table WHERE 1 GROUP BY employee_number;
Well. I found this statements and it works. Thanks guys.
1 Answer