mysql select query within a serialized array

前端 未结 14 1229
忘了有多久
忘了有多久 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".*'

    0 讨论(0)
  • 2020-11-29 08:17
    Select * from table where table_field like '%"enter_your_value"%'
    
    0 讨论(0)
提交回复
热议问题