Answer the question
In order to leave comments, you need to log in
How to find out how many identical records there are in a table?
Good evening!
I have a staff table with the following entries:
id name phone
1 Igor +79098987856
2 Alex 9637677676
3 Andrey +79655674587
4 Andrey 9655674587
5 Igor 9098987856
6 Ivan 9057688787
Answer the question
In order to leave comments, you need to log in
SELECT COUNT(*)
FROM (
SELECT RIGHT(`phone`, 10) AS `p_number`, COUNT(*) AS `p_number_count`
FROM `contacts`
GROUP BY `p_number`
HAVING `p_number_count` > 1
) AS `dupl_p_numbers`
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question