Unserialize through query at database level itself

后端 未结 8 561
清酒与你
清酒与你 2020-12-02 12:53

I have a column value stored in the database as:

a:2:{i:0;s:2:\"US\";i:1;s:2:\"19\";}

I want to unserialize it during the mysql

8条回答
  •  没有蜡笔的小新
    2020-12-02 13:42

    You can join your table simply in this way

        SELECT 
        table_to_join.ID as table_to_join_ID ,
        serialized_table.ID AS   serialized_table_ID,
    FROM
        table_to_join
            LEFT JOIN
        serialized_table  ON  serialized_table.array_field  REGEXP CONCAT_WS('','.s:[0-9];s:', table_to_join.ID ,';.') ;
    

    Take mention. I use index from 0 to 9 in table. If you have other indexes you must correct regexp

提交回复
热议问题