Description
This function decodes a URL-encoded string into its original form. It restores the characters corresponding to the two-digit hexadecimal numbers following the % symbol in expr. URL_ENCODE and URL_DECODE are inverse operations.
Considerations
- This function currently only supports the
utf8collation. - If the input is of the
stringtype, the output collation remains consistent with the input. If the input is not of thestringtype, the output collation is the default collation of the current session.
Syntax statement
URL_DECODE(expr)
Parameters
expr: The string that requires URL decoding.
Return type
- Returns a URL-encoded string (
VARCHARtype). - Returns
NULLif the value ofexprisNULL.
Examples
SELECT URL_DECODE('https%3A%2F%2Fexample.com%2Fpath%3Fname%3DJohn+Doe%26age%3D25'), URL_DECODE(NULL);
The return 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