like 搜索
create table name_db (
name varchar(20)
);
insert into name_db values
(‘abc‘),
(‘bac‘),
(‘bca‘);
select * from name_db where name like ‘a%‘; -- 不会匹配 bac
select * from name_db where name like ‘%a‘; -- 不会匹配 bac, like 表达式的内容是对整个结果的匹配, 可以使用 %a%
select * from name_db where name not like ‘%a‘; -- 匹配 abc, bac
select * from name_db where name not like ‘a%‘; -- 匹配 bac, bca
select * from name_db where name rlike ‘a‘; -- 匹配 3 个, rlike 表达式的内容只要部分匹配就满足
select * from name_db where name rlike ‘a[bc]‘;
select * from name_db where name not rlike ‘^a[bc]‘;