Mysql (6) string mode matching links: Mysql (1) mysql Installation http://www.bkjia.com/database/201210/162314.html Mysql (2) Database Operations http://www.bkjia.com/database/201210/162315.html Mysql (3) operations on Data Tables http://www.bkjia.com/database/201210/162316.html Mysql (4) Data Table query operations http://www.bkjia.com/database/201210/162317.html Mysql (5) operation time http://www.bkjia.com/database/201210/162318.html 1. Matching mysq in the standard SQL mode can use "_" to match any single character and "%" to match any number of characters. = Or! =, Use the LIKE or not like comparison operator. Example of www.2cto.com: 1. Find the name starting with "B" in the student table. SELECT * FROM student WHERE name LIKE "B %"; 2. Find the name ending with "B" in the student table. SELECT * FROM student WHERE name LIKE "% B"; 3. Find the name containing "B" in the student table. SELECT * FROM student WHERE name LIKE "% B %"; 4. Find the name exactly five characters in the student table. SELECT * FROM student WHERE name LIKE "_"; (there are spaces to indicate that there are five "_") 2. If regular expressions are used for pattern matching, we need to use another comparison operator, which is REGEXP or not regexp. Some Characters of the extended regular expression: "." matches any single character. "*" Matches zero or multiple characters before it. "X *" matches any number of X characters. Regular Expressions are case-sensitive and can be matched using a character class. [AA] matches lowercase and upper-case. "^" Indicates the beginning and "$" indicates the end. Example of www.2cto.com: 1. Find the name starting with "B" in the student table. SELECT * FROM student WHERE name REGEXP "^ [bB]"; 2. Find the name ending with "B" in the student table. SELECT * FROM student WHERE name REGEXP "[bB] $"; 3. Find the name containing "B" in the student table. SELECT * FROM student WHERE name REGEXP "[bB]"; 4. Find the name exactly five characters in the student table. SELECT * FROM student WHERE name REGEXP "^ _ $"; (there are spaces to indicate that there are 5 "_")