You are here: RE: [PHP] mysql select statement in php having three conditions « PHP « IT news, forums, messages
RE: [PHP] mysql select statement in php having three conditions

Posted by Jay Blanchard on 12/16/05 16:45

[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=''";

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация