我如何从 mysql 数据库中的序列化字段中搜索?

2021-12-21 00:00:00 sql serialization php mysql

除mysql like语句外,如何从mysql数据库的serialize字段中搜索?

How do i search from serialize field in mysql database except mysql like statement?

数据为:

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' 语句.

I need the row in which the m9 value is 'Yes It Is'. I do not want to use mysql 'like' statement.

我试过了:

SELECT * FROM table WHERE field like '%Yes It Is%'

你能帮忙吗.

推荐答案

您是否尝试过以下操作:

Have you tried the following:

SELECT * FROM table WHERE field like '%"m9";s:18:"Ok Then, Yes It Is";%'

?

但实际上,如果您想在此类数据中进行搜索,您应该简单地创建适当的表结构,而不是将所有序列化数据放在一列中

But in fact if you want to search in such data, you should simple create proper structure of your table and not to put all serialized data in one column

相关文章