- 0
- 0
- 约4.51千字
- 约 5页
- 2025-05-09 发布于北京
- 举报
--创建数据库
createdatabaseschool;
--创建表
useschool;
createtablestudent
(
stnointnotnull,
stnamechar(10)notnull,
stchar(2),
stageint
);
--数据
insertintostudentvalues(1,,M,35);
INSERTINTOstudent
values(2,,M,45),
(3,梅超风,F,35),
(4,欧阳锋,M,56),
(5,,M,25),
(6,小,F,18),
select*fromstudent;
--各种查询操作
--)查询所有的记录
select*fromstudent
--)查询满足条件的所有记录
select*fromstudent
wherestage40;
--3)查询所有记录的某些列
selectstname,stagefromstudent;
--4)查询满足条件的所有记录的某些列
selectstname,stagefromstudent
wherest=F;
--5)更改输出列的列名
selectstnameas,stageas,
fromstudent;
--6)对结果进行去重处理
selectdistinctstfromstudent;
--7)对结果按某一条件排序
select*fromstudentordwebystagedesc;
--where子句进阶
--1)比较表达式,=!===等等
select*fromstudentwherest=Forstage=40
--2)范围表达式,IN,notIN,betweenand,notbeweenand
select*fromstudentwherestage=35orstage=55orstage=60;
fromstudentwherestagenotin(35,45,55,65);
select*fromstudentwherestagenotbetween20and30;
--3)模式匹配like%_
select*fromstudentwherestnamelike张%;
select*fromstudentwherestnamelike张_;
--4)空值的使用
insertintostudentvalues(7,东方不败,null,180),
select*fromstudentwherenotstisnull;
--统计函数,聚合函数,max,min,avg,count,sum,var,stdev
selectAVG(stage)as平均fromstudent;
selectMAX(stage)as最大fromstudent;
selectMIN(stage)as最小fromstudent;
selectCOUNT(*)as总学生数fromstudent;
selectSUM(stage)as总和fromstudent;
selectVAR(stage)as方差fromstudent;
selectAVG(stage)as平均,
STDEV(stage)as标准差,
COUNT(*)as录数fromstudent;
--聚合函数的标配子句,where,groupby,having
--1)聚合函数+where子句
selectCOUNT(*)as
您可能关注的文档
最近下载
- 2023承压设备用钢板和钢带 第7部分:不锈钢和耐热钢.docx VIP
- 新媒体文案写作:爆款标题—吸睛有道PPT教学课件.pptx
- 英展 XK3150W-GTW防水计重电子台秤使用说明书.pdf VIP
- 2025年医疗AI应用:诊断辅助与效率提升报告.docx VIP
- 酒店安全风险分级管控和隐患排查治理双重预防机制建设指导书.pdf VIP
- DB34T 5428-2026电动汽车充电设施消防安全管理规范.pdf VIP
- 门店药品法律法规试卷题(食品安全法律法规考试试题及答案).docx VIP
- ASME B18.2.1-2012美标螺栓规范.pdf VIP
- 在线网课学习课堂《研究生生涯发展与规划(山大 )》单元测试考核答案.pdf VIP
- 《如何描述问题》课件.ppt VIP
原创力文档

文档评论(0)