How to search from serialization field in mysql database?

How to search from serialization field in mysql database except mysql statement?

Data:

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";} 

I need a line where m9 is "Yes It Is". I do not want to use the mysql 'like' statement.

I tried:

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

You can help.

+6
source share
2 answers

I found one solution using regex:

 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.*".*' 

Hope this helps:

http://www.namasteui.com/search-from-serialize-field-in-mysql-database/

+11
source

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 simply create the correct structure of your table and not put all the serialized data in one column

+5
source

Source: https://habr.com/ru/post/971588/


All Articles