content_image/779439.jpg content_image/779431.jpg content_image/779432.jpg
• expr  NOT LIKE pat  [ESCAPE ’ escape_char ’] 

This is the same as NOT ( expr  LIKE pat  [ESCAPE ’ escape_char ’]) . 

<img src='content_image/779439.jpg'>

+--------------+ 

To test for values that end with backslash, you can match the values using either of the following patterns: 

mysql> SELECT filename, filename LIKE ’%\\’ FROM t1; 

<img src='content_image/779431.jpg'>

mysql> SELECT filename, filename LIKE ’%\\\\’ FROM t1; 

<img src='content_image/779432.jpg'>

## Note 

Aggregate queries involving NOT LIKE  comparisons with columns containing NULL  may yield unexpected results. For example, consider the following table and data: 

CREATE TABLE foo (bar VARCHAR(10)); INSERT INTO foo VALUES (NULL), (NULL); 

The query SELECT COUNT(*) FROM foo WHERE bar LIKE ’%baz%’; returns 0 . You might assume that SELECT COUNT(*) FROM foo WHERE bar NOT LIKE ’%baz%’;  would return 2 . However, this is not the case: The second query returns 0 . This is because NULL NOT LIKE expr  always returns NULL , regardless of the value of expr . The same is true for aggregate queries involving NULL  and comparisons using NOT RLIKE  or NOT REGEXP . In such cases, you must test explicitly for NOT NULL  using OR  (and not AND ), as shown here: 

• STRCMP( expr1 , expr2 ) 

SELECT COUNT(*) FROM foo WHERE bar NOT LIKE ’%baz%’ OR bar IS NULL; 

STRCMP()  returns 0  if the strings are the same, -1  if the first argument is smaller than the second according to the current sort order, and 1  otherwise. 

mysql> SELECT STRCMP(’text’, ’text2’); -> -1 mysql> SELECT STRCMP(’text2’, ’text’); -> 1 mysql> SELECT STRCMP(’text’, ’text’); 

