Page 1 of 1
SELECT FROM WHERE Clause
Posted: Mon May 15, 2006 1:56 pm
by ianhull
Hi guys,
I need to select all the records in a table using the WHERE clause
but my problem is I need to select everything WHERE courseowner is not null or empty
Please help.
Thanks
Re: SELECT FROM WHERE Clause
Posted: Mon May 15, 2006 2:14 pm
by santosj
SQL is mostly a language construct.
Code: Select all
WHERE courseowner NOT NULL OR courseowner = ''
I would check the 'NOT NULL' text, you may have to use
Code: Select all
courseowner = NULL OR courseowner = ''
Posted: Mon May 15, 2006 2:31 pm
by ianhull
Thanks for this,
I have just tried it with no luck.
Any other suggestion very welcome.
thanks
Posted: Mon May 15, 2006 2:36 pm
by alex-weej
Which DBMS? MySQL? Postgres?
Posted: Mon May 15, 2006 2:37 pm
by ianhull
MySQL
Thanks
Posted: Mon May 15, 2006 2:39 pm
by santosj
Code: Select all
courseowner != NULL OR courseowner != ''
Posted: Mon May 15, 2006 2:41 pm
by alex-weej
Code: Select all
WHERE courseowner IS NOT NULL
AND courseowner != ''
"IS NOT NULL" is what you need.
Posted: Mon May 15, 2006 2:42 pm
by santosj
AND should be OR perhaps?
Unless to Mysql NULL and empty are the same thing, from my experience, if NULL, NULL would be in the field and if empty it would be used for NOT NULL fields.
Posted: Mon May 15, 2006 2:42 pm
by alex-weej
No
Posted: Mon May 15, 2006 2:45 pm
by santosj
Okay, yeah, I see your point, I have a difficult time with logic.
Posted: Mon May 15, 2006 2:45 pm
by ianhull
courseowner != ''
this works great
thank you.
Posted: Mon May 15, 2006 2:46 pm
by alex-weej
He phrased it "where courseowner is not null or empty"
Boolean logic converts that to "where courseowner is not null and courseowner is not empty".
Posted: Mon May 15, 2006 2:47 pm
by alex-weej
Ian, please include the check for "courseowner IS NOT NULL" because NULL is not the same as ''. If you have an actual NULL value in your database it won't match ''.