November 4, 2008 at 2:37 pm
Hi,
I'm trying to eliminate all rows where the column is either NOT NULL or contains spaces. So my query is something like this:
SELECT * FROM MYTABLE
WHERE (STATUS IS NOT NULL OR STATUS <> ' ')
The query eliminates the NULL's but still returns back the column with spaces.
Any ideas on what I'm doing wrong would be greatly appreciated??
November 4, 2008 at 2:53 pm
Change the OR to an AND.
November 5, 2008 at 2:26 am
Try this..
select * from mytable where isnull(ltrim(rtrim(status)),'')<>''
November 5, 2008 at 7:27 am
Thanks ever so much. That worked great.
November 5, 2008 at 7:38 am
WHERE STATUS>''
Failing to plan is Planning to fail
November 5, 2008 at 9:18 am
dale_keller (11/5/2008)
Thanks ever so much. That worked great.
Which way did you fix your problem?
November 5, 2008 at 9:19 am
I used this as an example:
select * from mytable where isnull(ltrim(rtrim(status)),'')<>''
works great!!!!
November 5, 2008 at 9:54 am
Sounds good. Again, just curious, did you try changing the OR to AND in your original query?
November 5, 2008 at 10:30 am
Yes, and it still did not work.
November 5, 2008 at 10:36 am
Lynn yours would work if you LTRIM RTRIM the status first.
----------------------------------------------
Try to learn something about everything and everything about something. - Thomas Henry Huxley
:w00t:
Posting Best Practices[/url]
Numbers / Tally Tables[/url]
November 5, 2008 at 10:49 am
Christopher Stobbs (11/5/2008)
Lynn yours would work if you LTRIM RTRIM the status first.
I thought so. I just attacked the obvious BOOLEAN error in the original code and didn't really notice that there could have been values with multiple spaces (ie ' ') since the code had status <> '' in the where clause.
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply