Reputation: 293
Using MS SQL Server Studio
How would I use a WHERE CONTAINS, involving a wildcard.
This is what I have currently tried,
SELECT [Store No]
,[Store Name]
FROM [dbo].[EUACTIVESTORES] EU
WHERE CONTAINS ( EU.[Store Name], ''%UTO%' or '%HAM%'')
And also tried
SELECT [Store No]
,[Store Name]
FROM [dbo].[EUACTIVESTORES] EU
WHERE EU.[Store Name] LIKE IN ('%UTO%','%HAM%')
Upvotes: 1
Views: 50
Reputation: 38509
You can't have LIKE IN
but you can have OR
SELECT [Store No],[Store Name]
FROM [dbo].[EUACTIVESTORES] EU
WHERE
EU.[Store Name] LIKE '%UTO%'
OR
EU.[Store Name] LIKE '%HAM%
Or, try a temporary table:
CREATE TEMPORARY TABLE nameLikes (
like VARCHAR(20)
);
INSERT INTO likes VALUES ('%UTO%'), ('%HAM%');
SELECT EU.[Store No],[Store Name]
FROM [dbo].[EUACTIVESTORES] EU
JOIN nameLikes n ON (EU.Name LIKE n.like);
Upvotes: 1
Reputation: 13237
You can use OR
operator with two separate LIKE
as below:
SELECT [Store No]
,[Store Name]
FROM [dbo].[EUACTIVESTORES] EU
WHERE EU.[Store Name] LIKE '%UTO%' OR
EU.[Store Name] LIKE '%HAM%'
Upvotes: 1
Reputation: 679
SELECT [Store No]
,[Store Name]
FROM [dbo].[EUACTIVESTORES] EU
WHERE EU.[Store Name] LIKE '%UTO%' or EU.[Store Name] LIKE '%HAM%'
Upvotes: 1