$pdo = $db->query('SELECT * FROM data ;');
$total = $pdo->rowCount();
echo $total;
The result is for example 3
.
But I have a column named "done" in mySQL database where the possible value is 1
or 0
.
I want now to count all rows with the value 1
. So if there are for example in total 9
elements in the database and from them three items with the value 1
then the result should be:
3/9
I know only know how to do this with a second database request
$pdo = $db->query('SELECT * FROM data WHERE done = "1" ;');
$done = $pdo->rowCount();
echo $done."/".$total;
But I was wondering if this is possible in just one database request.