Page 1 of 1

how to check exclude empty mysql field

Posted: Sat Mar 19, 2011 4:54 am
by seuntech
i have tried this but it is not working
i want to exclude search that the name field is empty

$query = "SELECT * FROM blogpost WHERE title LIKE \"%$trimmed%\" OR post LIKE \"%$trimmed%\" AND disable ='1' AND name IS NOT NULL";

Re: how to check exclude empty mysql field

Posted: Sat Mar 19, 2011 6:32 am
by Darhazer

Code: Select all

$query = "SELECT * FROM blogpost WHERE (title LIKE \"%$trimmed%\" OR post LIKE \"%$trimmed%\") AND disable ='1' AND name IS NOT NULL";

Re: how to check exclude empty mysql field

Posted: Sat Mar 19, 2011 10:58 am
by seuntech
thanks but it did not work it is still showing all rows that have empty name field

Re: how to check exclude empty mysql field

Posted: Sun Mar 20, 2011 2:20 am
by Zyxist
Then maybe they do not have a NULLvalue, but just an empty string? And empty strings are not considered as NULL-s.