写在前面
作者简介:鲸海鹿林
博客主页:鲸海鹿林的主页
名言警句:keep calm and carry on
SQL6-查找条件——是
例如:查找学生表中来自北京(city)的学生id和name
select id,name from students where city='北京'
where关键字后跟条件表达式,字符串要使用单引号'',不能使用双引号""
SQL7-查找条件——否
例如:查找学生表中不是来自北京(city)的学生id和name
select id,name from students where city NOT IN ('北京')
#或
select id,name from students where city != '北京'
#或
select id,name from students where NOT city='北京'
#或
select id,name from students where city<>'北京'
在条件表达式之前使用NOT关键字表示否,
!=表示不等于
NOT IN后跟group表示不在组中
<>也表示不等于
SQL7-查找条件——大于,小于
例如:查找学生表中年龄大于20且小于23的学生id和name
select id,name from students where age>20 AND age<23
条件语句且关系使用AND关键字连接;或关系使用OR关键字。
SQL8-查找条件——在...之间
例如:查找学生表中年龄大于20且小于23的学生id和name也可使用在20与23之间:
select id,name frome students where age between 20 AND 23
SQL8-查找条件——过滤空值
例如:查找学生表中年龄不为空值的学生id和name
select id,name frome students where age is not null
可以直接使用is not null来过滤
SQL9-查找条件-包含字段
例如:查找学生表中姓张的学生
select * from students where name like '张%'