If I have a simple SELECT statement:
SELECT JSON_EXTRACT('{"username":"Alexander"}', '$.username');
I expect him to return Alexander , but instead return "Alexander" . "Alexander" How can I get rid of quotes? Why does this function even return quotes?
Alexander
"Alexander"
you can use replace () with it to remove quotes
SELECT replace(JSON_EXTRACT('{"username":"Alexander"}', '$.username'), '\"', '');
You can use JSON_UNQUOTE to achieve this.
JSON_UNQUOTE
select JSON_UNQUOTE(JSON_EXTRACT(base, '$.scope')) as scope from t_name
link:
You can use SUBSTRING
SELECT SUBSTRING( JSON_EXTRACT ( '{"username":"Alexander"}', '$.username' ), 2, ( LENGTH( JSON_EXTRACT ( '{"username":"Alexander"}', '$.username' ) ) - 2 ) );