Creating a search query which ignore null values

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
swiftguy
Forum Newbie
Posts: 2
Joined: Tue Aug 29, 2006 10:04 am

Creating a search query which ignore null values

Post by swiftguy »

Hello Experts,

In our php application we are trying to code a search process where in we need to extract data from a table , the user can enter one or more fields listed in the link below

http://www.strokefx.com/4ss-7Aug06/ibs/ ... earch.html .

The user may enter one or more fields,but if we use 'like' clause its retrieving all the records, can somebody guide me in coding a efficient MySQL query which ignores null fields (the fields which are left blank in the above form) and retrieves only those records whose values have been entered in the form fields.


Tried out 'ifnull()' mysql function but its not helpful.


Thx in advance!

Regards,
Swiftguy.
ody
Forum Contributor
Posts: 147
Joined: Sat Mar 27, 2004 4:42 am
Location: ManchesterUK

Post by ody »

An example would be:

Code: Select all

select * from tbl_name where col0 IS NOT NULL
Post Reply