How does mysql extract JSON data?

when dealing with the data of a mysql table, it is encountered that the content stored in a field is as follows:

a:2:{
    i:0;
    a:2:{i:0;i:0;i:1;s:9:"";}
    i:1;
    a:2:{i:0;i:0;i:1;s:9:"";}
}

I want to use sql to put forward the names and generate characters such as "Zhu Taiping, Liu Zhongfu" . How can I extract them?

Mar.08,2022

this is not JSON data, but PHP serialized data. It is difficult to extract


as mentioned above, this is not JSON format, but PHP serialized data, which is actually a two-dimensional array:

Array
(
    [0] => Array
        (
            [0] => 0
            [1] => 
        )

    [1] => Array
        (
            [0] => 0
            [1] => 
        )

)

it is not easy to extract strings directly with SQL. If you are using PHP, you can use PHP's method:

echo join(',', array_map(function($a) { return $a[1]; }, unserialize($data)));
  • MySQL Json int type array query

    the simple table structure is as follows < table > < thead > < tr > < th > ID < th > < th > TypeID < th > < tr > < thead > < tbody > < tr > < td > 1 < td > < td > [1,2] < td > < tr > < tr > < td > 2 < td > < td > [2,3] < td > < tr...

    Oct.22,2021
  • How does mysql extract JSON data?

    when dealing with the data of a mysql table, it is encountered that the content stored in a field is as follows: a:2:{ i:0; a:2:{i:0;i:0;i:1;s:9:"";} i:1; a:2:{i:0;i:0;i:1;s:9:"";} } I want to use sql to put forwa...

    Mar.08,2022
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5217b-451a2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5217b-451a2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?