我如何从mysql类语句以外的mysql数据库中的序列化字段中搜索?
数据为:
a:9:{s:2:"m1";s:4:"1217";s:2:"m2";s:8:"9986-961";s:2:"m3";s:19:"1988-03-07 00:00:00";s:2:"m4";s:0:"";s:2:"m5";s:0:"";s:2:"m6";s:0:"";s:2:"m7";s:3:"104";s:2:"m8";s:6:"150000";s :2:"m9";s:18:"Ok Then, Yes It Is";}
我需要其中m9值为“是,是”的行。我不想使用mysql的“ like”语句。
我努力了:
SELECT * FROM table WHERE field like '%Yes It Is%'
你能帮忙吗?
我发现一种使用正则表达式的解决方案:
SELECT * FROM table_name WHERE `field` REGEXP '.*"array_key";s:[0-9]+:".*array_value.*".*' SELECT * FROM table_name WHERE `field` REGEXP '.*"m9";s:[0-9]+:".*Ok Then, Yes It Is.*".*'
希望这可以帮助:
http://www.namasteui.com/search-from-serialize-field-in-mysql- database/