Multiple count in php



I’ve got to use multiple counts in php. Now I do it like this:

[php]$res5 = mysql_query(“SELECT count(cars) FROM mytable WHERE car=‘bmw’ and cars!=’’”) or die(mysql_error());
$res6 = mysql_query(“SELECT count(boats) FROM mytable WHERE boat=‘bavaria’ and boats!=’’”) or die(mysql_error());
$res7 = mysql_query(“SELECT count(motos) FROM mytable WHERE moto=‘suzuki’ and moto!=’’”) or die(mysql_error());
They fields are all in the same table. Is there a way to have on select instead of three?
I would appreciate your help.
Thanks in advance


Yes. Union, or a self join works. But, stop using old mysql_ functions and hop on the PDO bandwagon.
The data model looks like a wreck though.


The first thing you need to do is fix your database design. You need to learn about database normalization.