Link to home
Start Free TrialLog in
Avatar of metalaureate
metalaureateFlag for United States of America

asked on

Using LIKE with IN

Experts,

I have a query of the form

Select Field1 from T1
where Field1 not in
(Select Excluded_Values from T2)

I want the T2 table values to be wildcard-matched against Field1 (i.e. for the IN match to be a LIKE). LIKE creates an error. Anyone know how I do this?
Avatar of arbert
arbert

I guess we need a little more to go on....Like, like you said is usually used with a wild card--how many characters do you want to match????  
Avatar of metalaureate

ASKER

I have  list of IP addresses to exclude, i.e.

66.180.5.%
128.1.4.%

etc.

I want to exclude all records  that match these IP masks.

The problem arose when my list of excluded IP addresses grew too large for concaternations of (AND NOT LIKE '66.180.5.%') etc. etc.
SOLUTION
Avatar of jchopde
jchopde

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks. You got it.

Both jchopde and appari's answer achieve the same results, but jchopde's solution is 600% faster. Anyone know why?