comma separated argument for IN operator, MySQL

前端 未结 2 453
滥情空心
滥情空心 2021-01-21 05:56

I have a table in which the following query works fine:

select * 
from session_actions 
where action_type IN (\'login_failed\',\'channel_recorded\')


        
相关标签:
2条回答
  • 2021-01-21 06:31

    You might be looking for FIND_IN_SET() function.

    select * 
    from session_actions 
    where find_in_set(`action_type`,'login_failed,channel_recorded');
    

    SAMPLE FIDDLE

    0 讨论(0)
  • 2021-01-21 06:49

    I tried FIND_IN_SET but it was super slow. I rather use haystack REGEXP CONCAT('[[:<:]]', needle, '[[:>:]]') since then.

    0 讨论(0)
提交回复
热议问题