开发者

read element of serialize field in mysql

开发者 https://www.devze.com 2023-01-24 21:27 出处:网络
i ran this query on mysql: select rc_details from apitbl limit 1; the result is a:7:{s:6:\"itemid\";s:9:\"PCO FLEXI\";s:2:\"op\";s:1:\"P\";s:3:\"cir\";s:1:\"*\";s:3:\"api\";s:1:\"3\";s:3:\"loc\";s

i ran this query on mysql:

select rc_details from apitbl limit 1;

the result is

a:7:{s:6:"itemid";s:9:"PCO FLEXI";s:2:"op";s:1:"P";s:3:"cir";s:1:"*";s:3:"api";s:1:"3";s:3:"loc";s:1:"P";s:4:"type";s:1:"F";s:4:"mode";s:1:"T";}

My Problem:

i want to extract elements from the serialize fields to run query as:

select rc_开发者_高级运维details from apitbl where (itemid='PCO FLEXI');


Something like this might do it:

SELECT rc_details FROM apitbl WHERE rc_details REGEXP '.*"itemid";s:[0-9]+:"PCO FLEXI".*'

Anyway it's much better to create additional table and store this info there.

0

精彩评论

暂无评论...
验证码 换一张
取 消