赞
踩
like模糊查询,支持%和下划线匹配,%匹配多个字符,_下划线:任意一个字符
示例:
1、查询名字中含有张的学生信息
select * from student where sname like ‘%张%’;
2、查询名字以张开头的学生信息
select * from student where sname like ‘张%’;
3、查询名字以人结尾的学生信息
select * from student where sname like ‘%人’;
4、查询名字中第二个字为心的学生信息
select * from student where sname like ‘_心%’;
5、查询名字中第三个字为心的学生信息
select * from student where sname like ‘__心%’;
因为下划线在sql中有特殊含义,所以当查询姓名中有下划线的学生信息时需要转义
示例:
select * from student where sname like ‘%_%’;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。