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 and the basic syntax of it is as shown below:

QUOTE(String_Expression)

MySQL QUOTE Function Example

The 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 method.

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

SELECT QUOTE('Tutorial''Gateway');

SELECT QUOTE('Tutorial \'Gateway');
Quote Example 1

You can also use this one on a column Data. This MySQL example shows you how to use this method in the Email column.

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