0

I have a table which good have entries with the same content (multiple) on three fields, which have a different id (pk).

Table example:

id, fld1, fld2, fld3, fld4, datetime, date, fld5, fld6, fld7
(247234, 5, 501, 20, 3, '2015-09-02 05:48:23', '2015-09-02', NULL, NULL, 21),
(247299, 5, 501, 20, 1, '2015-09-02 06:40:50', '2015-09-01', NULL, NULL, 21),
(247364, 5, 501, 20, 2, '2015-09-02 06:40:54', '2015-09-01', NULL, NULL, 21),
**(247429, 5, 501, 20, 3, '2015-09-02 06:40:58', '2015-09-04', NULL, NULL, 21),**
(247494, 5, 501, 20, 1, '2015-09-02 06:41:02', '2015-09-04', NULL, NULL, 21),
(247559, 5, 501, 20, 2, '2015-09-02 06:41:05', '2015-09-04', NULL, NULL, 21),
(247624, 5, 501, 20, 4, '2015-09-02 06:41:09', '2015-09-04', NULL, NULL, 21),

**(247689, 5, 501, 20, 3, '2015-09-02 06:41:12', '2015-09-04', NULL, NULL, 21),**
(247754, 5, 501, 20, 5, '2015-09-02 06:41:15', '2015-09-04', NULL, NULL, 21),
(247819, 5, 499, 20, 3, '2015-09-02 06:41:18', '2015-09-04', NULL, NULL, 21),

I must remove one or more entries from the table who have the same content.

Can I found a solution in mysql or do I have to write a script?

aimme
  • 6,385
  • 7
  • 48
  • 65
J. Deloers
  • 13
  • 4
  • 4
    Yes, its called **if at first you dont succeed, Try, try again!** SO is not a **free coding resource** You have to have a go at it first and if you cannot get it working, we are more than willing to help. But **we do not work from specification, not even good ones** – RiggsFolly Sep 05 '15 at 21:30

1 Answers1

1

This has been answered here.

Once you clean up your table, you should create a unique constraint that is defined by a combination of columns, and add error handling for this case in your application.

Community
  • 1
  • 1
curtis1000
  • 106
  • 6