数据库基础命令

  1. 查询指定列
    select sno,sname,ssex
    from student;

  2. 查询所有列
    select *
    from student;

  3. 使用计算
    select sno,cno,grade*0.6
    from sc;

  4. 使用列别名
    select sno,cno,grade*0.6 as 期末成绩
    from sc;

  5. 去掉重复
    select distinct sno
    from sc;

  6. 排序
    select *
    from student
    order by sage ;

select *
from student
order by sage desc;
二、 条件查询

  1. 比较运算符 > < = >= <= <>
    select *
    from student
    where ssex <> ‘男’;

select *
from student
where sage >= 20;
2. 逻辑运算符 and or not
select *
from student
where sage >= 20 and ssex = ‘男’;

select *
from student
where sage >= 20 or ssex = ‘男’;
3. 区间运算符
select sno,cno,grade
from sc
where grade between 60 and 90;

select sno,cno,grade
from sc
where grade not between 60 and 90;
4. 模糊查询 like 通配符: % _
select *
from student
where sname like ‘张%’;

select *
from student
where sname like ‘张_’;

select *
from student
where sname like ‘张__’;

select *
from course
where cname like ‘%数据%’;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值