在哪里有包含野生动物卡片的声明

时间:2017-06-28 14:48:30

标签: sql-server where

使用MS SQL Server Studio

我如何使用涉及通配符的WHERE CONTAINS。

这是我目前所尝试的,

SELECT [Store No]
      ,[Store Name]
FROM [dbo].[EUACTIVESTORES] EU
WHERE CONTAINS ( EU.[Store Name], ''%UTO%' or '%HAM%'') 

还试过

SELECT [Store No]
   ,[Store Name]
    FROM [dbo].[EUACTIVESTORES] EU
WHERE EU.[Store Name] LIKE IN ('%UTO%','%HAM%')

3 个答案:

答案 0 :(得分:1)

<div class="wrapper">
  <p>Hey, how you're doing? .</p>
</div>

答案 1 :(得分:1)

您可以将OR运算符与两个单独的LIKE一起使用,如下所示:

SELECT [Store No]
   ,[Store Name]
    FROM [dbo].[EUACTIVESTORES] EU
WHERE EU.[Store Name] LIKE '%UTO%' OR 
      EU.[Store Name] LIKE '%HAM%'

答案 2 :(得分:1)

您不能拥有LIKE IN,但可以拥有OR

SELECT [Store No],[Store Name]
FROM [dbo].[EUACTIVESTORES] EU
WHERE 
EU.[Store Name] LIKE '%UTO%'
OR 
EU.[Store Name] LIKE '%HAM%

或者,尝试临时表:

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);