mysql select query within a serialized array

前端 未结 14 1307
忘了有多久
忘了有多久 2020-11-29 07:51

I\'m storing a list of items in a serialized array within a field in my database (I\'m using PHP/MySQL).

I want to have a query that will select all the records that

14条回答
  •  一生所求
    2020-11-29 08:10

    There is a good REGEX answer above, but it assumes a key and value implementation. If you just have values in your serialized array, this worked for me:

    value only

    SELECT * FROM table WHERE your_field_here REGEXP '.*;s:[0-9]+:"your_value_here".*'

    key and value

    SELECT * FROM table WHERE your_field_here REGEXP '.*"array_key_here";s:[0-9]+:"your_value_here".*'

提交回复
热议问题