RE: mysql select statement in php having three conditions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[snip]
  can someone tell me how to do this:
  i have to retrive data from a mysql table let's sayTABLE . i have to
check that the rows i retrive meet this condition:
field1='$variable',field2 is false and field3 is also false. as you
can see field2 and field3 are bool type. field1 is varchar. i did this
query "SELECT * FROM TABLE WHERE field1='$variable' AND field2='0' AND
field3='0'"; another one tried is "SELECT * FROM TABLE WHERE
field1='$variable' AND field2=false AND field3=false"; But none was a
success. it didn't matter whether i used '0' or 0 and false or
'false'.
  thanks in advance.
[/snip]

That is likely because the data is either blank or NULL , try;

"SELECT * FROM TABLE WHERE field1='$variable' AND field2 IS NULL AND field3=
IS NULL "; 

or

"SELECT * FROM TABLE WHERE field1='$variable' AND field2='' AND field3=''"; 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux