Thread: Help with Query Needed
June 27th, 2005, 06:26 PM #1
Help with Query Needed
Ok, I'm stuck. I've read what I have in front of me and Googled around but can't seem to get this.
I'm trying to search a database that has both <NULL> values AND blank values for the same field in different records. I need to filter out both. Here's what I have so far:
SELECT DISTINCT DestCity FROM OppPrimary2 WHERE (DestCity IS NOT NULL) ORDER BY DestCity
The DestCity field is a VARCHAR with a 19 character space limit. The SQL server is MS SQL Server 2000 if that matters.
Any suggestions?Where's Lunch?
June 27th, 2005, 06:42 PM #2
Try something like:
SELECT DISTINCT DestCity
WHERE (DestCity IS NOT NULL) OR (DestCity IS NOT "")
ORDER BY DestCity
IS NOT may actually be <>
Last edited by cyclist110; June 27th, 2005 at 06:47 PM.C.
June 27th, 2005, 09:14 PM #3
- Join Date
- Sep 2002
You're almost right. Should be:
SELECT DISTINCT DestCity FROM OppPrimary2 WHERE (DestCity IS NOT NULL) AND (DestCity <> '') ORDER BY DestCity
June 27th, 2005, 11:19 PM #4
I think the AND will be a problem, it'll look for DestCity being not equal to NULL AND not equal to ' ', whereas using the OR says give me anything that is not equal NULL OR ' '. As for the rest I fully agree.C.
June 28th, 2005, 10:38 AM #5Originally Posted by CreosoteWhere's Lunch?
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
By kiwitech in forum General Gaming DiscussionReplies: 4Last Post: October 9th, 2008, 06:36 PM
By Doot in forum Applications and Operating SystemsReplies: 6Last Post: January 2nd, 2004, 09:45 PM
By BitSpit in forum Distributed ComputingReplies: 2Last Post: September 12th, 2003, 09:45 PM
By kickzum in forum Applications and Operating SystemsReplies: 6Last Post: August 30th, 2002, 05:28 PM