MySQL QUOTE Function

MySQL QUOTE function is one of the String Functions, which returns a string enclosed by a single quotation mark. Or you can use this Quote function to escape the data value, i.e., backslash, single quote, ASCII NULL. Let us see how to write MySQL String QUOTE Function with an example. The basic syntax of QUOTE of a string in MySQL is as shown below:

QUOTE(String_Expression)

MySQL QUOTE Example

The string QUOTE function escapes the backslash and single quote in a given string, and returns the string surrounded by single quotations. The following query shows multiple ways to use this QUOTE function.

SELECT QUOTE('Don\'t Do it');

SELECT QUOTE('Tutorial''Gateway');

SELECT QUOTE('Tutorial \'Gateway');
MySQL QUOTE Function 1

You can also use this QUOTE function on a column Data. This MySQL example shows you how to use this String Function in the Email column.

SELECT FirstName,
LastName,
      DepartmentName,
      QUOTE(DepartmentName),
      Email,
      QUOTE(Email)
FROM `MySQL Tutorial`.employe;
MySQL QUOTE Function 2