I have a table named telco which has 2 columns, id(PK) and telco_prov. I want to count the duplicate records in the telco_prov column, then display the number of times it appeared.
telco table example:
id telco_prov
1 Smart
2 Smart
3 Globe
4 Globe
5 Globe
Here is my code:
$query = "select telco_prov, count(*) c from telco group by telco_prov having c > 1";
$result = mysql_query($query) or die('Error: '.mysql_error ());
$row = mysql_fetch_assoc($result);
echo "SMART: <font color= 'red'>".$row['c']."</font>";
echo "<br>GLOBE: <font color= 'red'>".$row['c']."</font>";
The code has no error, but it doesn't do the counting correctly.
The result from the code above:
SMART: 2
GLOBE: 2
But it should be:
SMART: 2
GLOBE: 3
I've tried adding where statement in the query but still it doesn't work.
$query = "select telco_prov, count(*) c from telco where telco_prov = 'Smart' group by telco_prov having c > 1";
Your help would be much appreciated. Thanks!