I have this query which returns a list of rows as well as the amount of time they are repeated, with a column TotalCount :
SELECT X,
COUNT(*) as TotalCount
FROM table
GROUP BY X HAVING COUNT(*) > 1
ORDER BY COUNT(*) DESC
I execute this query in PHPMyadmin :
[X] [TotalCount]
A 5
B 6
I try to include the query in my script, but the following gives me '2' :
echo $result->num_rows;
How to get the '11' in PHP?
EDIT:
My query is :
$sql="
SELECT X,
COUNT(*) as TotalCount
FROM table
GROUP BY X HAVING COUNT(*) > 1
ORDER BY COUNT(*) DESC
";
$result = $conn->query($sql);
echo $result->num_rows;
I am trying to do something like
echo $row[TotalCount];
The initial table is
[X]
A
A
A
A
A
B
B
B
B
B
B
$resultand what representsnum_rowsin it.