Extract data from json inside mysql field

前端 未结 5 1373
无人共我
无人共我 2021-01-04 20:47

I\'ve got a a table with rows, and one of the rows has a field with data like this

{\"name\":\"Richard\",\"lastname\":null,\"city\":\"Olavarria\",\"cityId\":         


        
5条回答
  •  灰色年华
    2021-01-04 21:08

    This may be a little late, but the accepted answer didn't work for me. I used SUBSTRING_INDEX to achieve the desired result.

    SELECT 
        ID, SUBSTRING_INDEX(SUBSTRING_INDEX(JSON, '"mykey" : "', -1), '",', 1) MYKEY
    FROM MY_TABLE;
    

    Hope this helps.

提交回复
热议问题