i want to count and display each duplicate value in a column from the below table using php mysql
name
AAA
BBB
BBB
BBB
AAA
CCC
result should be like below
AAA-2
BBB-3
CCC-1
i want to count and display each duplicate value in a column from the below table using php mysql
name
AAA
BBB
BBB
BBB
AAA
CCC
result should be like below
AAA-2
BBB-3
CCC-1
select name, count(name) as count from table_name group by name
SELECT name, COUNT(name) c_name FROM tablename GROUP BY name HAVING c_name>1
<?php
require_once('connection.php');
$result=mysqli_query($conn,
"SELECT colum_name, concat(count(1),'-',colum_name)
as colum_name
FROM table_name
group by colum_name
order by colum_name desc");
while ( $data=mysqli_fetch_assoc($result)) {
echo $data['colum_name']."<br>";
}