M
M
mrnagaron2018-03-31 00:26:22
MySQL
mrnagaron, 2018-03-31 00:26:22

How to find duplicates in MySQL?

Hello , how to do search and delete in MYSQL database? Through PHP?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sanovskiy, 2018-03-31
@mrnagaron

We look for duplicates by grouping by value and filtering those that are less than two.
Example

SELECT
    valueField1,
    valueField2,
    count(*)
FROM
    myTable
GROUP BY
    valueField1,
    valueField2
HAVING
    count(*)>1

Be sure to include all relevant fields.
Delete on what basis? All but the first one you see?

A
Alexander, 2018-03-31
@zkelo

The search for duplicates can be implemented with a regular SELECTquery, and the removal, respectively, with the help of DELETE.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question