not like

description

syntax

BOOLEAN not like(VARCHAR str, VARCHAR pattern)

Perform fuzzy matching on the string str, return false if it matches, and return true 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. +-------+
  10. // Return data that does not contain a in the k1 string
  11. mysql> select k1 from test where k1 not like '%a%';
  12. +-------+
  13. | k1 |
  14. +-------+
  15. | b |
  16. | bb |
  17. +-------+
  18. // Return the data that is not equal to a in the k1 string
  19. mysql> select k1 from test where k1 not like 'a';
  20. +-------+
  21. | k1 |
  22. +-------+
  23. | b |
  24. | bb |
  25. | bab |
  26. +-------+

keywords

  1. LIKE, NOT, NOT LIKE