Find value in comma delimited string mysql

前端 未结 3 1171
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-17 08:07

I have a table in my DB that looks like so:

member_id    name    mgroup_others    member_group_id
    1        Name1      2,3,10              1
    2                 


        
3条回答
  •  一生所求
    2021-01-17 08:45

    Since mgroup_others is a varchar column what if you simply use LIKE operator other than FIND_IN_SET() like

    select * from table1
    where mgroup_others like '%10'
    

    You can as well use FIND_IN_SET() like below

    select * from table1
    where find_in_set(10,mgroup_others)
    

    See a demo fiddle here http://sqlfiddle.com/#!2/034711/2

提交回复
热议问题