常用sql语句

写在前面
创建表‘sc’代表学生成绩单;
创建属性‘con’代表‘课程’,容我失策‘cno’写成‘con’;
创建属性‘sno’代表学生的学号;
创建属性‘score’代表分数;


基础篇

  1. 查询所有列:*代表all
    select * from sc;

  2. 查询指定列:直接加属性名
    select score from sc;

  3. 去重:添加‘distinct’
    select distinct score from sc;

  4. 条件查询:添加where,还有like、in、and、or
    select score from sc where score>70;

  5. 排序:order by 属性
    select score from sc order by score desc(/asc);

  6. 分页:前面pageindex,后面pagenumber
    select * from sc limit 0,5;
    select * from sc limit 5,5;

  7. 插入
    insert into sc (con,sno,score)values(1,11,99);

  8. 更新
    update sc set score = 88 where sn0 = 11;

  9. 删除
    delete from sc where sno = 10;

  10. as
    select distinct a.sno from
    (select sno,score from sc where con = 1) a,
    (select sno,score from sc where con = 2)b
    where a.score > b.score
    order by a.sno
    limit 0,10;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值