URL_DECODE
Description
This function is used to decode a URL-encoded string into its original form. It converts the % followed by two hexadecimal digits in expr back to the corresponding character. URL_ENCODE and URL_DECODE are inverse operations.
Considerations
- This function currently only supports the
utf8character set. - If the input is of type
string, the output collation remains consistent with the input. If the input is not of typestring, the output uses the default collation of the current session.
Syntax
URL_DECODE(expr)
Parameters
expr: the string to be URL-decoded.
Return Type
- Returns a URL-decoded string (
VARCHARtype). - Returns
NULLifexprisNULL.
Examples
SELECT URL_DECODE('https%3A%2F%2Fexample.com%2Fpath%3Fname%3DJohn+Doe%26age%3D25'), URL_DECODE(NULL);
The result is as follows:
+-----------------------------------------------------------------------------+------------------+
| URL_DECODE('https%3A%2F%2Fexample.com%2Fpath%3Fname%3DJohn+Doe%26age%3D25') | URL_DECODE(NULL) |
+-----------------------------------------------------------------------------+------------------+
| https://example.com/path?name=John+Doe&age=25 | NULL |
+-----------------------------------------------------------------------------+------------------+
1 row in set (0.020 sec)