alchemist Posted May 25, 2006 Share Posted May 25, 2006 Hi folksI have a database to store simple entries on goods coming in which contains 4 columns such as:goods date department signedoffIf 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 | JeffP4 Comp | 060522 | Admin | JeffP3 COmp | 060522 | | JamesLappy | 060426 | | BlakeIpod | 060411 | Admin | BlakeAnd 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 | | JamesLappy | 060426 | | BlakeAny idea how I could make it strip out the empty rows?Thanks very much for any help.Regards,Dave Quote Link to comment https://forums.phpfreaks.com/topic/10408-query-returning-empty-rows/ Share on other sites More sharing options...
eves Posted May 26, 2006 Share Posted May 26, 2006 SELECT * FROM mydb WHERE (Goods='lappy' OR Date LIKE '%25') AND (Dept IS NOT NULL OR Dept!='') Quote Link to comment https://forums.phpfreaks.com/topic/10408-query-returning-empty-rows/#findComment-39070 Share on other sites More sharing options...
alchemist Posted May 26, 2006 Author Share Posted May 26, 2006 Ahhh all fixedThanks Eves, much appreciated mate. Quote Link to comment https://forums.phpfreaks.com/topic/10408-query-returning-empty-rows/#findComment-39072 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.