写在前面
创建表‘sc’代表学生成绩单;
创建属性‘con’代表‘课程’,容我失策‘cno’写成‘con’;
创建属性‘sno’代表学生的学号;
创建属性‘score’代表分数;
基础篇
-
查询所有列:*代表all
select * from sc; -
查询指定列:直接加属性名
select score from sc; -
去重:添加‘distinct’
select distinct score from sc; -
条件查询:添加where,还有like、in、and、or
select score from sc where score>70; -
排序:order by 属性
select score from sc order by score desc(/asc); -
分页:前面pageindex,后面pagenumber
select * from sc limit 0,5;
select * from sc limit 5,5; -
插入
insert into sc (con,sno,score)values(1,11,99); -
更新
update sc set score = 88 where sn0 = 11; -
删除
delete from sc where sno = 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;
网友评论