1、like 操作符
说明:用于在 WHERE 子句中搜索列中的指定模式。
实例:
搜索用户名为'123'的用户。
select * from users where username like '123';
2、% 通配符
说明:替代一个或多个字符。
实例:
(1)搜索用户名包含'123'的用户
select * from users where username like '%123%';
(2)搜索用户名以'123'开头的用户
select * from users where username like '123%';
(3)搜索用户名以'123'结尾的用户
select * from users where username like '%123';
3、_ 通配符
说明:仅代替一个字符。
实例:
(1)搜索用户名以'123'开头,但不能是'123'的用户
select * from users where username like '123%_';
(2)搜索用户名以'123'结尾,但不能是'123'的用户
select * from users where username like '_%123';
(3)搜索用户名不以'123'开头,不以'123'结尾,以'123'在中间的用户 &n


5177

被折叠的 条评论
为什么被折叠?



