模糊查询
作者:互联网
-- 查询姓刘的同学
-- like 结合 %(表示0到任意个字符) _(表示一个字符)
select `studentNo`, `studentName` from student where studentName LIKE '刘%'
-- 查询姓刘的同学后面分别只有一个字的,两个字的
select `studentNo`, `studentName` from student where studentName LIKE '刘_'
select `studentNo`, `studentName` from student where studentName LIKE '刘__'
-- 查询姓名中间有一个嘉字的
select `studentNo`, `stundetName` from student where studentName LIKE '%嘉%'
-- in
-- 查询1001,1002,1003号
select `studentNo`, `studentName` from student where studentNo IN (1001,1002,1003)
-- 查询在北京的学生
select `studentNo`, `studentName` from student where address IN ('北京', '安徽')
-- null not null
select `studentNo`, `studentName` from student where address='' OR adress IS NULL
-- 查询有出生日期的同学
select `studentNo`, `studentName` from student where BornDate !='' OR BornDate IS NOT NULL
-- 查询没有出生日期的同学
select `studentNo`, `studentName` from student where BornDate IS NULL
标签:studentName,--,模糊,查询,studentNo,student,where,select 来源: https://www.cnblogs.com/gss01/p/16642954.html