Solved

Another way of coding this where-clause

Posted on 2012-03-11
2
178 Views
Last Modified: 2012-03-18
I have this where clause that i needed to modify. I want to exlcude
any values 050102xxxx (the first 6 values start with 050102).

I did it by adding an "and" clause. You can see this value is in the OR clause already. Can I exlcude in the OR clause?

where  (    m.loc_id   LIKE '2001%' 
           OR m.loc_id LIKE '2002%'
           OR m.loc_id LIKE '2003%'
           OR m.loc_id LIKE '1001%'
           OR m.loc_id LIKE '1003%' 
           OR m.Loc_ID LIKE '1002%' 
           OR m.loc_id  BETWEEN '0008000000' AND '0171999999' 
           [b]OR m.Loc_ID BETWEEN '0501000000' AND '0501999999'  [/b]          
          )   [b]and m.loc_id not like '050102%'[/b] 

Open in new window

0
Comment
Question by:Camillia
2 Comments
 
LVL 7

Accepted Solution

by:
micropc1 earned 500 total points
ID: 37707948
Maybe...

 OR (m.Loc_ID LIKE '0501%' AND m.Loc_ID NOT like '050102%')
0
 
LVL 32

Expert Comment

by:ewangoya
ID: 37708598
That is pretty OK, it has to be on an AND condition outside the parenthesis as you put it.
Should be fine
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
This video discusses moving either the default database or any database to a new volume.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now