Jump to content

Archived

This topic is now archived and is closed to further replies.

alchemist

Query returning empty rows

Recommended Posts

Hi folks

I have a database to store simple entries on goods coming in which contains 4 columns such as:

goods date department signedoff

If I have entries in the database that don't contain a department and I do a query to select a keyword but leave my search form blank for department, it also returns all the blank entries under department.

For example, I have entries in the DB containing this:

Goods | Date | Dept | Signedoff
---------------------------------------------------
Laptop | 060525 | IT | Jeff
P4 Comp | 060522 | Admin | Jeff
P3 COmp | 060522 | | James
Lappy | 060426 | | Blake
Ipod | 060411 | Admin | Blake


And I do a query for example:

select * from mydb where Goods like 'Lappy' or Date like '' or Dept like '' or Signedoff like ''

It will return the following rows:

P3 Comp | 060522 | | James
Lappy | 060426 | | Blake


Any idea how I could make it strip out the empty rows?

Thanks very much for any help.

Regards,
Dave

Share this post


Link to post
Share on other sites
SELECT * FROM mydb WHERE (Goods='lappy' OR Date LIKE '%25') AND (Dept IS NOT NULL OR Dept!='')

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.