mysql select query within a serialized array

前端 未结 14 1306
忘了有多久
忘了有多久 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 07:57

    You can do it like this:

    SELECT * FROM table_name WHERE some_field REGEXP '.*"item_key";s:[0-9]+:"item_value".*'
    

    But anyway you should consider storing that data in a separate table.

提交回复
热议问题