3

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

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

Now I'm looking forward to some thing like the following:

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

As you see I want to give the IN operator one single comma separated parameter, but it is not possible

How can I convert this comma separated string into a list of parameters which is acceptable to IN operator?

2 Answers 2

3

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.