0

This is a illustration of my table.

id    |  stocks  | colour
0156  |   in     |  red
5482  |  out     |  red
5488  |  out     | yellow

I need to get 3 row counts. How is it possible to the 3 different types of COUNT values in a query?

$sql="SELECT count(*) FROM tbl, 
        (SELECT count(*) FROM tbl WHERE stock = 'out'),
        (SELECT count(*) FROM tbl WHERE colour= 'yellow')";
$statement = $connect->prepare($sql);
$statement->execute();
$row = $statement->fetch(PDO::FETCH_NUM);
$val_tot = $row[0]; //? 
Becky
  • 5,467
  • 9
  • 40
  • 73

0 Answers0