Jump to content


Photo

Query returning empty rows


  • Please log in to reply
2 replies to this topic

#1 alchemist

alchemist
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 25 May 2006 - 03:21 AM

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

#2 eves

eves
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 26 May 2006 - 01:16 AM

SELECT * FROM mydb WHERE (Goods='lappy' OR Date LIKE '%25') AND (Dept IS NOT NULL OR Dept!='')



#3 alchemist

alchemist
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 26 May 2006 - 01:43 AM

Ahhh all fixed

Thanks Eves, much appreciated mate.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users