With SQL can you use a sub-query in a WHERE LIKE clause?
- by Jason
I'm not even sure how to even phrase this as it sounds weird conceptually, but I'll give it a try. Basically I'm looking for a way to create a query that is essentially a WHERE IN LIKE SELECT statement.
As an example, if I wanted to find all user records with a hotmail.com email address, I could do something like:
SELECT UserEmail
FROM Users
WHERE (UserEmail LIKE '%hotmail.com')
But what if I wanted to use a subquery as the matching criteria? Something like this:
SELECT UserEmail
FROM Users
WHERE (UserEmail LIKE (SELECT '%'+ Domain FROM Domains))
Is that even possible? If so, what's the right syntax?