2016-04-20 449 views
0

我想說如果事件中包含'%webinar%','%network%'包含它「如果」日期在01之後-04-2015。我無法在單獨的行上使用「或」,因爲它忽略了日期。任何幫助讚賞。如何在「in」語句中使用%SQL

select 
    ,fsa.eventid 
    ,sev.EventStart 
    from 
    event sev 
    on 
    sev.eventId = fsa.eventid 
    where sev.SNAP_EventStart >= '2015-04-01' 
    and eventidname in ('%webinar%','%network%') 
+1

您可以用'或'如果你把正確的paranthesis ...(運算符優先級,'和''之前或')' – SomeJavaGuy

+5

..和(eventidname LIKE '%研討會%' 或eventidname LIKE'%network%')' – Mihai

+0

[爲SQL Server組合「LIKE」和「IN」)可能重複(http://stackoverflow.com/questions/1865353/combining-like-and-in-for-sql-服務器) – GSerg

回答

2

請儘量

... where sev.SNAP_EventStart >= '2015-04-01' 
    and (eventidname like '%webinar%' or eventidname like '%network%') 
0

嘗試這種方式

SELECT * 
FROM table t INNER JOIN 
     (
      SELECT '%webinar%' Col 
      UNION SELECT '%network%' col 
     ) a ON t.COLUMN LIKE a.Col 
-1

試試這個。

select ,fsa.eventid ,sev.EventStart from event sev on sev.eventId = fsa.eventid where sev.SNAP_EventStart >= '2015-04-01' and
( Patindex('%webinar%', eventidname) = 1 OR Patindex('%network%', eventidname) = 1 )