how to check exclude empty mysql field

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
seuntech
Forum Newbie
Posts: 13
Joined: Thu Feb 24, 2011 4:54 pm

how to check exclude empty mysql field

Post 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";
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: how to check exclude empty mysql field

Post 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";
seuntech
Forum Newbie
Posts: 13
Joined: Thu Feb 24, 2011 4:54 pm

Re: how to check exclude empty mysql field

Post by seuntech »

thanks but it did not work it is still showing all rows that have empty name field
User avatar
Zyxist
Forum Contributor
Posts: 104
Joined: Sun Jan 14, 2007 10:44 am
Location: Cracow, Poland

Re: how to check exclude empty mysql field

Post by Zyxist »

Then maybe they do not have a NULLvalue, but just an empty string? And empty strings are not considered as NULL-s.
Post Reply