or和and的使用

or和and的使用

查找学生姓名以’李’开头或者年龄为’20’的学生信息

select *from student where name like '李%' or age = '20'

查找学生姓名以’李’开头并且年龄为’20’的学生信息

select *from student where name like '李%' and age = '20'

查找学生姓名以’李’开头或者年龄为’20’性别为’女’的学生信息

select *from student where name like '李%' or age = '20' and sex = '女'

查找学生姓名以’李’开头性别为’女’或者年龄为’20’性别为’女’的学生信息

select *from student where (name like '李%' or age = '20') and sex = '女'

between的使用

查找学生年龄在20到21之间(包含20和21)的学生信息

select *from student where age between 20 and 21

查找学生年龄不在20到21之间(包含20和21)的学生信息

select *from student where age not between 20 and 21

in的使用

查找学生年龄在20到21之间(包含20和21)的学生信息

select *from student where age in('20','21')
相当于
select *from student where age = '20' or age = '21'

查找学生年龄不在20到21之间(包含20和21)的学生信息

select *from student where age not in('20','21')

is null 和增加列

上面我们没有地址这一列数据,现在我们插入地址列,增加信息

更新数据添加一列

alter table student
add address varchar(10)

查询更新后的信息


select *from student

更新增加列的内容

update student
set address = '北京'
where id = '3'

update student
set address = '上海'
where id = '4'

update student
set address = '广州'
where id = '5'

update student
set address = '深圳'
where id = '6'

update student
set address = '北京'
where id = '7'

我们增加一部分内容即可,不要全部增加

查询地址是否为空

select *from student where address is null

查询地址是否不为空

select *from student where address is not null
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

走到无路可退

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值