QUOTE() function returns the string surrounded by single quotations and escapes the backslash in it.
The MySQL QUOTE() function quotes a string to produce a result that can be used as a properly escaped data value in an SQL statement. The string is returned enclosed by single quotation marks and with each instance of backslash (\), single quote (‘), ASCII NUL, and Control+Z preceded by a backslash.
Returns value is the word “NULL” without enclosing single quotation marks if the input is NULL. See example 2. It is useful in saving the values in the database.
[table caption=”” width=”100%” colwidth=”15%|15%|15%|55%” colalign=”left|left|left|left”]
Name, Required /Optional,Type, Description
string, Required, String , It represents the valid input (already) escaped string..
[/table]
[table caption=”” width=”100%” colwidth=”100%” colalign=”left”]
Return
string surrounded by single quotations and escapes the backslash in it.
Returns value is the word “NULL” without enclosing single quotation marks if the input is NULL.[/table]
[table caption=”” width=”100%” colwidth=”25%|75%” colalign=”left|left”]
Version, MySQL 5.7
[/table]
it makes MySQL‘s handling of the full string easier by covering the string with single quotes, and by preceding every single quote, backslash, ASCII NUL, and control-Z with a backslash. See the below example:
mysql> SELECT QUOTE('Shouldn\'t!'); +----------------------+ | QUOTE('Shouldn\'t!') | +----------------------+ | 'Shouldn\'t!' | +----------------------+ 1 row in set (0.05 sec)
The above example has returned the same string as input. while below example add \(backslash) to single quotation mark(‘).
mysql> SELECT QUOTE('Shouldn''t!'); +----------------------+ | QUOTE('Shouldn''t!') | +----------------------+ | 'Shouldn\'t!' | +----------------------+ 1 row in set (0.00 sec)
See below example
mysql> SELECT QUOTE(NULL); +-------------+ | QUOTE(NULL) | +-------------+ | NULL | +-------------+ 1 row in set (0.00 sec)
The QUOTE operator is often used to enclosed with a single quote for all employee’s names. See below example
mysql> select name, QUOTE(name) from tbl_employee; +------------+--------------+ | name | QUOTE(name) | +------------+--------------+ | Jyoti Rani | 'Jyoti Rani' | | Polla | 'Polla' | | Arnav | 'Arnav' | | Jeevesh | 'Jeevesh' | | Tom | 'Tom' | +------------+--------------+ 5 rows in set (0.03 sec)
See all MySQL String functions MySQL 8 String Functions.
App usage is growing steadily without showing any signs of slowing down. Hence, it is no surprise that mobile applications…
As the world has grown more digital, businesses have adapted themselves. An effectual adaptation includes online advertising. Offline advertising styles…
Step into a world where apps dance to the user's tune. Picture Instagram, a photo-sharing sensation that swept the globe.…
COVID-19 has led to a digitalization of lifestyle. As patients are taking their mental and physical health more seriously, healthcare…
Introduction WordPress, an immensely popular content management system (CMS), powers over 40% of the internet. What makes WordPress even more…
For moving companies trying to capture their market share amidst stiff competition, a tip or two about what they can…