Sourav Basak
Sourav Basak

Reputation: 486

How do i search from serialize field in mysql database?

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

The data is:

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 the row in which the m9 value is 'Yes It Is'. I do not want to use mysql 'like' statement.

I have tried:

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

Can you please help.

Upvotes: 9

Views: 18789

Answers (1)

Marcin Nabiałek
Marcin Nabiałek

Reputation: 111829

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

Upvotes: 5

Related Questions