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
Table of contents 1. Basic types 2. Object Type 2...
This article shares with you the tutorial of inst...
Some time ago, when I was working on a small func...
Idea: Just sort randomly first and then group. 1....
What is a sticky footer layout? Our common web pa...
Autotrash is a command line program that automate...
HTML implements 2-column layout, with fixed width...
Table of contents Constructing payment methods us...
Previously, my boss asked me to make a program th...
Flappy Bird is a very simple little game that eve...
Preface The similarities and differences between ...
Table of contents Vue2.x Usage Global Registratio...
MySQL has the following logs: Error log: -log-err...
I just learned mybatis today and did some simple ...
This article example shares the specific code of ...