UNQUOTE()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Xpand
Topics on this page:
Overview
Returns a string with removed surrounding quotes and removed backslash escapes.
USAGE
UNQUOTE(string)
Argument Name | Description |
---|---|
| The string to unquote |
DETAILS
UNQUOTE()
is a string function that returns a string with removed surrounding quotation marks and removed backslash escapes.
The input argument can be surrounded by either single quotes or double quotes. If the starting character and ending character are not a single/double quote or they don't match, the string is returned unchanged.
When quotes are removed, the return value is also modified to remove backslash escaping: the way to get a backslash in the result is for the input to contain 2 backslash characters in a row.
Certain improperly escaped inputs might return an unexpected output, such as a 1-character string of a quote turning into an empty string. However, properly encoded quoted strings always return a properly unquoted string.
For the reverse operation, see QUOTE().
A NULL
is returned if the argument is NULL
.
EXAMPLES
SET @chk = '"testing \\"one two\\"!"';
SELECT @chk, UNQUOTE(@chk)\G
*************************** 1. row ***************************
@chk: "testing \"one two\"!"
UNQUOTE(@chk): testing "one two"!
SET @chk = QUOTE('I \\ can\'t \\ decide.');
SELECT @chk, UNQUOTE(@chk)\G
*************************** 1. row ***************************
@chk: 'I \\ can\'t \\ decide.'
UNQUOTE(@chk): I \ can't \ decide.
SET @chk = '"hi\'';
SELECT @chk, UNQUOTE(@chk)\G
*************************** 1. row ***************************
@chk: "hi'
UNQUOTE(@chk): "hi'
SELECT UNQUOTE('"'), UNQUOTE('"\\"');
+--------------+-----------------+
| UNQUOTE('"') | UNQUOTE('"\\"') |
+--------------+-----------------+
| | |
+--------------+-----------------+