如何从mysql中的json中提取数据

时间:2016-11-28 09:30:37

标签: php mysql json

尝试从mysql中的json中提取数据: 我的示例mysql查询是: 我已经尝试使用下面的代码,但它返回null值,但我在数据库中有价值。 在下面的代码中,column_name1和er_trading_sales是列名,table_name是表的名称

    SELECT column_name1 as column_name1,
        substring(
        er_trading_sales,
        locate('"C2":{"type":"label","value":"":{"m":"label","k":"(a) to registered       dealers","v":"}","C3": {    "type":"textbox","value":"',er_trading_sales,locate('"Trading_B_I"',er_trading_s ales))+70,
    (locate('"},"C4',er_trading_sales,locate('"C2":{"type":"label","value":"":{"m":"label","k":"(a) to registered dealers","v":"}","C3":{"type":"textbox","value":"',er_trading_sales,locate('"Trading_B_I"',er_trading_sales))) - (locate('"C2":{"type":"label","value":"":{"m":"label","k":"(a) to registered dealers","v":"}","C3":       {"type":"textbox","value":"',er_trading_sales,locate('"Trading_B_I"',er_trading_     sales))+70))
     ) as TradingAmount
      from table_name

    //sample json
     "R10" => array(
                "col_data" => array(
                    "CR1" => array(
                        "C1" => array(
                            "type" => "label",
                            "value" => "8.",
                        ),
                        "C2" => array(
                            "type" => "complex",
                            "value" => array(
                                "m" => "label",
                           "k" => "Turnover of sale of goods taxable @ ^d^%",
                                "v" => "4.5"
                            ),
                        ),
                          "C3" => array(
                            "type" => "textbox",
                            "value" => "",
                            "validation" => "decimal",
                          ),
                             "C4" => array(
                            "type" => "textbox",
                            "value" => "",
                            "validation" => "decimal",
                            'htmlOptions' => array('readonly' => 'readonly'),
                          ),
                          "C5" => array(
                            "type" => "",
                            "value" => "",
                          ),
                    ),
                ),
            ),


   i want "value" of   "C3" => array(
                        "type" => "textbox",
                        "value" => "",
                        "validation" => "decimal",
                    ) 

0 个答案:

没有答案