How do i search from serialize field in mysql database?

17,396

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

Share:
17,396
Sourav Basak
Author by

Sourav Basak

Everybody gets so much information all day long that they lose their common sense. [email protected] http://www.namasteui.com/ https://www.facebook.com/namasteui https://twitter.com/namasteui https://plus.google.com/+Namasteuimag

Updated on July 26, 2022

Comments

  • Sourav Basak
    Sourav Basak almost 2 years

    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.