like
description
syntax
BOOLEAN like(VARCHAR str, VARCHAR pattern)
Perform fuzzy matching on the string str, return true if it matches, and false if it doesn’t match.
like match/fuzzy match, will be used in combination with % and _.
the percent sign (‘%’) represents zero, one, or more characters.
the underscore (‘_‘) represents a single character.
1. 'a' // Precise matching, the same effect as `=`
2. '%a' // data ending with a
3. 'a%' // data starting with a
4. '%a%' // data containing a
5. '_a_' // three digits and the middle letter is a
6. '_a' // two digits and the ending letter is a
7. 'a_' // two digits and the initial letter is a
8. 'a__b' // four digits, starting letter is a and ending letter is b
example
1. // table test
2. +-------+
3. | k1 |
4. +-------+
5. | b |
6. | bb |
7. | bab |
8. | a |
9. +-------+
11. // Return the data containing a in the k1 string
12. mysql> select k1 from test where k1 like '%a%';
13. +-------+
14. | k1 |
15. +-------+
16. | a |
17. | bab |
18. +-------+
20. // Return the data equal to a in the k1 string
21. mysql> select k1 from test where k1 like 'a';
22. +-------+
23. | k1 |
24. +-------+
25. | a |
26. +-------+
keywords
1. LIKE
