MariaDB QUOTE() Function

In MariaDB, QUOTE() is a built-in string function that returns a string enclosed in single quotes so that it is suitable for inclusion in an SQL statement.

MariaDB QUOTE() Syntax

Here is the syntax of the MariaDB QUOTE() function:

QUOTE(str)

Parameters

str

Required. a string.

If you provide the wrong number of parameters, MariaDB will report an error: ERROR 1582 (42000): Incorrect parameter count in the call to native function 'QUOTE'.

Return value

The MariaDB QUOTE(str) function returns a string surrounded by single quotes.

If the argument is NULL, the QUOTE() function will return as a string NULL.

MariaDB QUOTE() Examples

Here’s a basic example:

SELECT
  QUOTE("Let's go!"),
  QUOTE('Let''s go!'),
  QUOTE('Let\'s go!');

Output:

+--------------------+---------------------+---------------------+
| QUOTE("Let's go!") | QUOTE('Let''s go!') | QUOTE('Let\'s go!') |
+--------------------+---------------------+---------------------+
| 'Let\'s go!'       | 'Let\'s go!'        | 'Let\'s go!'        |
+--------------------+---------------------+---------------------+

Conclusion

In MariaDB, QUOTE() is a built-in string function that returns a string enclosed in single quotes so that it is suitable for inclusion in an SQL statement.