07-SQLite like, wildcard (%,-, [char list], [^ char list], [! Char list]), 07-sqlitechar
I. Overview of like
The like operator is used to search for the specified mode syntax in the where clause: select column_name (s) from table_name where column_name likepattern;
2. Select data whose addr starts with "s" from the persons Table
Syntax: select * from persons where addr like's % '; Note: The above % is a wildcard (the part missing in the mode), as long as the first letter is s.
3. Select data whose addr ends with "j" from the persons Table
Syntax: select id, addr from persons where addr like '% J ';
4. Select the data information that addr contains "z" from the persons Table
Syntax: select * from persons where addr like '% z % ';
5. Select addr data that does not contain "z" from the persons table.
Syntax: select * from persons where addrnot like '% z % ';
6. SQL wildcards
Overview: the SQL wildcard can replace one or more characters, but must be used with the like
Wildcard |
Description |
% |
Replace one or more characters |
_ |
Replace only one character |
[Char list] |
Any character in the character Column |
[^ Char list] |
Any character not in the character Column |
[! Char list] |
Any character not in the character Column |
7. Use wildcards
Example 1: select the data information of "zb" after the first letter in the addr column from persons.
Note: [char list] results cannot be obtained in sqlite3