-1

I have table_a. This table contains columns are, Col1,col2,col3,col4,co5,col6,col7.

I need to delete duplicate records of col1 to col5.

I mean,

I'd.     Col1  col2    col3    col4   col5
-------  ----  ----    ----    ----   ----

1.        A.    B.      C.       D.    E
2.        B.    D.      R.       Y.    U
3.        A.    B.      C.       D.    E
4.        A.    B.      C.       D.    E
5.        W.    E.      R.       T.    Y
6.        W.    E.      R.       T.    Y

I want result id is only 1,2,5

Anybody know to design the MySQL query please paste the solution here.

Hamid Pourjam
  • 20,441
  • 9
  • 58
  • 74
Logu
  • 11
  • 4

2 Answers2

2

Try this:

SELECT MIN(id), col1,col2,col3,col4,col5
FROM `table_a`
GROUP BY col1,col2,col3,col4,col5;
Will
  • 24,082
  • 14
  • 97
  • 108
Ye Lwin Soe
  • 356
  • 2
  • 8
-2

you can use this query to delete duplicate records

DELETE FROM table_a WHERE id IN (SELECT id FROM table_a GROUP BY id HAVING COUNT(*) > 1) LIMIT 1

this return your answer

chetan
  • 249
  • 3
  • 6