HiveBrain v1.2.0
Get Started
← Back to all entries
snippetMajor

How to remove string quotes in MySQL 5.7 for function JSON_EXTRACT?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
functionquotesremovemysqlforjson_extracthowstring

Problem

Other than doing string manipulation after each JSON_EXTRACT, is there a simpler or more correct way to have the JSON_EXTRACT return the string WITHOUT the enclosing quotes?

Or should this question be on StachExchange?

Solution

If you have MySQL 5.7.13 or later, you may use JSON_UNQUOTE() instead of JSON_EXTRACT() or ->> instead of ->. Example:

SELECT field->>"$.foo.barr" FROM table;

Context

StackExchange Database Administrators Q#143576, answer score: 41

Revisions (0)

No revisions yet.