Solved

Another way of coding this where-clause

Posted on 2012-03-11
2
180 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Date from a string 4 64
SQL help 5 54
Table create permissions on SQL Server 2005 9 41
Sql Server group by 10 25
So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

813 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

14 Experts available now in Live!

Get 1:1 Help Now