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

后端 未结 2 974
感情败类
感情败类 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

提交回复
热议问题