MySQL escapeEscape means the original semantics of the escape character. The purpose of an escape character is to start a character sequence so that the character sequence starting with the escape character has different semantics than when the character sequence appears alone. In MySQL, the escape character starts with "\". The escape characters commonly used in programming are all valid in MySQL and will not be described or discussed here. Here, the role of the ESCAPE keyword is mainly explained through "%" and "_". %: Matches any number of characters. _: Matches a single character. If we want to match "%" or "_", we must use "\" to escape, as follows: ### Query users whose names contain the character "明"> SELECT * FROM user WHERE name LIKE CONCAT("%", "明", "%") ### Query users whose names contain the % character> SELECT * FROM user WHERE name LIKE CONCAT("%", "\%", "%") Usage of ESCAPEThe main function of the ESCAPE keyword is to specify a character to replace the "\". ### Query users whose names contain the "%" character> SELECT * FROM user WHERE name LIKE CONCAT("%", "$%", "%") ESCAPE "$" ### Query users whose names contain the "_" character> SELECT * FROM user WHERE name LIKE CONCAT("%", "a_", "%") ESCAPE "a" It should be noted that all characters indicated by ESCAPE in the query conditions will replace the function of "\". ### Assume there are two users named %a and %_> SELECT * FROM user WHERE name LIKE "a%_" ESCAPE "a" ### %a %_ > SELECT * FROM user WHERE name LIKE "a%a" ESCAPE "a" ### %a > SELECT * FROM user WHERE name LIKE "a%a_" ESCAPE "a" ### %_ This is the end of this article on the detailed usage of the ESCAPE keyword in MySQL. For more relevant MySQL ESCAPE keyword content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
>>: HTML table markup tutorial (6): dark border color attribute BORDERCOLORDARK
Linux uses iftop to monitor the traffic of the ne...
HTML img produces an ugly blue border after addin...
This article example shares the specific code of ...
I. Strict Mode Explanation According to the restr...
1. Write Shell script crontab.sh #!/bin/bash step...
# contains a location information. The default anc...
My environment: 3 centos7.5 1804 master 192.168.1...
1. Command Introduction The usermod (user modify)...
Preview versions of Safari (Technology Preview 10...
Error screenshot Can't find where the excepti...
1. Introduction When filtering unknown or partial...
This article records the specific method of insta...
You can go to the Ubuntu official website to down...
This article is the second article about objects ...
Table of contents 1. Global level 2. Database lev...