简体   繁体   中英

how can i use % in an “in” statement SQL

I'm trying to say if the event has '%webinar%','%network%' in the name include it "if" the date is after the 01-04-2015. I cant use "or" on a separate line as it ignores the date. Any help appreciated.

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%')

please try

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

Try this way

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

尝试这个。

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 )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM