We help IT Professionals succeed at work.

Another way of coding this where-clause

Camillia
Camillia asked
on
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

Comment
Watch Question

Senior Analyst - Technology
CERTIFIED EXPERT
Commented:
Maybe...

 OR (m.Loc_ID LIKE '0501%' AND m.Loc_ID NOT like '050102%')
Ephraim WangoyaSoftware Engineer
CERTIFIED EXPERT

Commented:
That is pretty OK, it has to be on an AND condition outside the parenthesis as you put it.
Should be fine

Explore More ContentExplore courses, solutions, and other research materials related to this topic.