NOT LIKE
This page is part of MariaDB's Documentation.
The parent of this page is: SQL Operators for MariaDB Xpand
Topics on this page:
Overview
Negated pattern matching.
USAGE
value NOT LIKE text
value NOT LIKE text ESCAPE character
Value Name | Description |
---|---|
| A value expression |
| A text string with optional wildcards |
DETAILS
The NOT LIKE
operator works in a similar manner to the LIKE operator but with the opposite return value. See that operator's description for how the wildcard text and optional escape character works.
EXAMPLES
CREATE TABLE not_like_example (
description VARCHAR(20),
example INT
);
INSERT INTO not_like_example VALUES
('Everything', 42),
('Dalmations', 101),
('Agent', 99),
('100% Done', 13),
('CPU', 64);
SELECT *
FROM not_like_example
WHERE description NOT LIKE '%ing'
AND description NOT LIKE '____t%';
+-------------+---------+
| description | example |
+-------------+---------+
| Dalmations | 101 |
| 100% Done | 13 |
| CPU | 64 |
+-------------+---------+
-- Match descriptions without a percent
SELECT *
FROM not_like_example
WHERE description NOT LIKE '%\\%%';
+-------------+---------+
| description | example |
+-------------+---------+
| Everything | 42 |
| Dalmations | 101 |
| Agent | 99 |
| CPU | 64 |
+-------------+---------+
-- Match descriptions without a percent using alternate escape character
SELECT *
FROM not_like_example
WHERE description NOT LIKE '%=%%' ESCAPE '=';
+-------------+---------+
| description | example |
+-------------+---------+
| Everything | 42 |
| Dalmations | 101 |
| Agent | 99 |
| CPU | 64 |
+-------------+---------+