I am wondering if something is possible to do in mysql. I have one row of data in a mysql table and I would like to select all the information that is not equal to zero. I'd imagine there is a way to do this in PHP or mysql, but I am unable to find that.
For example I've got CGoals = 5, CAssists = 3, CPIM = 0, CPlusMinus = 0. I wanna select just CGoals and CAssists. However there will be many different cases where different variables will be different values.
Any help would be appreciated.
mySQL Select
Moderator: General Moderators
Code: Select all
$res=mysql_query("select * from table");
while($q=mysql_fetch_assoc($res)){
foreach($q as $name=>$data){
if($data!==0){
echo "$name=>$data\n";
}
}
echo "--------------\n";
}I don't think it's possible in SQL without any dirty hacks.