L
L
leha782015-12-08 06:29:18
PHP
leha78, 2015-12-08 06:29:18

How to sort table by DISTINCT but select all fields?

There is a table with a bunch of fields. It also contains a bunch of duplicate entries. I need to filter them by two fields, title and phone. Let's say I sort using DISTINCT, half of the 7000 records remain (duplicates are eliminated). But if you save, then only these fields are saved. I need to sort by two fields but still select all to keep. What request can be made? Or maybe there are ways in PHP?
UPDATE
SELECT * FROM `companies` GROUP BY title, phone
In this case, is this the correct query to weed out duplicates?
UPDATE 2
Issue resolved.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2015-12-08
@leha78

If these are complete duplicate records, then just SELECT DISTINCT *
If the other fields are different, and you don't care which of the duplicate records get into the selection, then GROUP BY

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question