I am trying to find a way, if possible, to use IN and LIKE together. I want to execute a subquery that pulls a list of data into an IN statement. The problem is that the data list contains wildcards. Is there any way to do this?
Just what I was interested in.
Example of data in the 2 tables Parent table ID Office_Code Employee_Name 1 GG234 Tom 2 GG654 Bill 3 PQ123 Chris Second table ID Code_Wildcard 1 GG% 2 PQ%
Clarification Note (via third-party)
Since I see several answers that do not seem to affect what Ziltoid asks, I thought that I would try to clarify what, in my opinion, he means.
In SQL, " WHERE col IN (1,2,3) " is roughly equivalent to " WHERE col = 1 OR col = 2 OR col = 3 ".
He is looking for something that I will be pseudo-code like
WHERE col IN_LIKE ('A%', 'TH%E', '%C')
which would be roughly equivalent
WHERE col LIKE 'A%' OR col LIKE 'TH%E' OR col LIKE '%C'
Regex answers seem closest; the rest look uneasy.
sql
Ziltoid
source share