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

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

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

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

提交回复
热议问题