First, the basic usage LIKE operator
LIKE operator is used in the WHERE clause, search for similar, similar data.
LIKE operator Syntax:
SELECT 1 column name, column name 2 ... FROM table name WHERE column LIKE xxx;
Example student table:
example:
SELECT * FROM student WHERE student_number LIKE "201902%";
operation result:
Second, use the NOT keyword
By NOT keyword, the search may not be similar, no similar data.
The syntax is as follows:
SELECT 1 column name, column name 2 ... FROM table name WHERE column NOT LIKE xxx;
example:
SELECT * FROM student WHERE student_number NOT LIKE "201902%";
operation result:
Third, Tsuhaifu
_: Indicates replace a character.
%: Represents one or more characters in place.
[]: Indicates matches any single character [] within ([] MySQL and SQLite do not support, will be treated as ordinary characters).
[^]: That does not match any single character [^] in the (^ only SQL Server support, [] MySQL and SQLite do not support, will be treated as ordinary characters).
_example:
SELECT * FROM student WHERE student_number LIKE '_0190201';
operation result:
%example:
SELECT * FROM student WHERE student_number LIKE '201902%';
operation result: