Skip to main content
Version: V1.0.0

QUOTE

Declaration

quote(str)

Description

Escaping the string to get a result can properly escape data values in an SQL statement.

In general, the returned string is enclosed in single quotation marks (').

In each case, a backslash () is added before a backslash (), a single quotation mark (`), a control character corresponding to the ASCII NUL character, or a Ctrl+Z.

If the parameter is NULL, it returns the 'NULL' string without single quotes.

Example

SELECT QUOTE('Don\'t!');
+------------------+
| QUOTE('Don\'t!') |
+------------------+
| 'Don\'t!' |
+------------------+
1 row in set (0.000 sec)

SELECT QUOTE(NULL);
+-------------+
| QUOTE(NULL) |
+-------------+
| NULL |
+-------------+
1 row in set (0.001 sec)

SELECT LENGTH(QUOTE(NULL));
+---------------------+
| LENGth(QUOTE(NULL)) |
+---------------------+
| 4 |
+---------------------+
1 row in set (0.001 sec)