MySQL - How to select rows where value is in array?

前端 未结 4 717
北海茫月
北海茫月 2020-12-07 22:20

Ok, normally I know you would do something like this if you knew the array values (1,2,3 in this case):

SELECT * WHERE id IN (1,2,3)

But I

4条回答
  •  温柔的废话
    2020-12-07 23:14

    Use the FIND_IN_SET function:

    SELECT t.*
      FROM YOUR_TABLE t
     WHERE FIND_IN_SET(3, t.ids) > 0
    

提交回复
热议问题