Hello. 40 thousand records. A lot of records with the same headings (exactly in exactly). Task: search for duplicates and display them with an identifier.

I try

$array=array(); $db_query="select id_advert, name_adv from ".DB_PREF."advert "; list($kol,$data)=obr_db_query_select_assoc($db_query);//ассоциативный массив foreach($data as $one){ $array[]=$one['name_adv']; } $array=array_count_values($array); 

I get the output => number of repetitions

I believe that I am not moving in the right direction, so I want to know your advice. In this case, how can I add id_advert to the result of repetitions?

    1 answer 1

     SELECT name_adv, GROUP_CONCAT(DISTINCT id_advert) identifiers_list FROM advert GROUP BY name_adv HAVING COUNT(DISTINCT id_advert) > 1 

    If the pairs (name_adv, id_advert) are guaranteed unique - DISTINCT can be removed.

    • Thank. It helped - Sarkis Allahverdian