mysql select query within a serialized array

前端 未结 14 1315
忘了有多久
忘了有多久 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:59

    If I have attribute_dump field in log table and the value in one of its row has

    a:69:{s:9:"status_id";s:1:"2";s:2:"id";s:5:"10215"}
    

    If I want to fetch all rows having status_id is equal to 2, then the query would be

    SELECT * FROM log WHERE attribute_dump REGEXP '.*"status_id";s:[0-9]+:"2".*'
    

提交回复
热议问题