QUOTE

2023-12-25 08:49:42  Updated

Syntax

QUOTE(str)

Purpose

QUOTE() quotes a string to generate a result that can be used as a properly escaped value in an SQL statement.

Generally, the returned string is generated by enclosing the original string in a pair of single quotation marks (').

A backslash (\) is added before each backslash (\), single quotation mark ('), ASCII NUL, and Control+Z.

If the argument is NULL, the return value is also NULL, without single quotation marks.

Examples

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

obclient> SELECT QUOTE(NULL);
+-------------+
| QUOTE(NULL) |
+-------------+
| NULL        |
+-------------+
1 row in set

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

Contact Us