How can I use JSON_EXTRACT in MySQL and get a string without the quotes?

后端 未结 2 972
感情败类
感情败类 2021-01-03 21:24

If I have a simple SELECT statement like this:

SELECT JSON_EXTRACT(\'{\"username\":\"Alexander\"}\', \'$.username\');

I would expect it to

相关标签:
2条回答
  • 2021-01-03 22:05

    You can use JSON_UNQUOTE to achieve this.

    select JSON_UNQUOTE(JSON_EXTRACT(base, '$.scope')) as scope from t_name
    

    ref: Functions That Modify JSON Values

    0 讨论(0)
  • 2021-01-03 22:09

    you can use replace() with it to remove quotation marks

    SELECT replace(JSON_EXTRACT('{"username":"Alexander"}', '$.username'), '\"', '');
    
    0 讨论(0)
提交回复
热议问题