【MySQL】Select * From查询语句集合
- 查询student表中的所有记录的sname,ssex,class列
select SNAME,SSEX,CLASS from student;
- 查询教师所有的单位即不重复的Depart列
select distinct DEPART from teacher;
- 查询Student表的所有记录
select * from student;
- 查询Score表中成绩在60到80之间的所有记录
select * from score where degree between 60 and 80;
- 查询Score表中成绩为85,86或88的记录
select * from score where degree=85 or degree=86 or degree=88;
- 查询Student表中“95031”班或性别为“女”的同学记录
select * from student where class='95031' and ssex='女';
- 以Class降序查询Student表的所有记录
select * from student order by class desc;
- 以Cno升序、Degree降序查询Score表的所有记录
select * from score order by degree desc , cno;
- 查询“95031”班的学生人数
select count(*) as '人数' from student where class='95031';
- 查询Score表中的最高分的学生学号和课程号
select * from score order by degree desc limit 1;
- 查询‘3-105’号课程的平均分
select avg(degree) from score where CNO='3-105';
- 查询Score表中至少有5名学生选修的并以3开头的课程的平均分数
select cno,avg(degree) from score where cno like '3%' group by cno having count(sno)>5;
- 查询最低分大于70,最高分小于90的Sno列
select sno from score group by sno having min(degree)>70 and max(degree)<90;
- 查询所有学生的Sname、Cno和Degree列.
Select sname,cno ,degree from student inner join score on student.sno=scire.sno;
- 查询“95033”班所选课程的平均分
Select cno,avg(degree) as avg from score where sno in(select sno from student where class=’95033’)group by cno;
- 查询选修“3-105”课程的成绩高于“109”号同学成绩的所有同学的记录
Select degree from score where sno=’109’ and cno=’3-105’;
- 查询score中选学一门以上课程的同学中分数为非最高分成绩的记录
Select sno from score group by sno having count(*)>1;
Select * from score where sno in (Select sno from score group by sno having count(*)>1)
- 查询所有教师和同学的name、sex和birthday
select sname as name,ssex as sex,sbirthday as birthday from student union select tname as name,tsex as sex,tbirthday as birthday from teacher;
- 查询所有“女”教师和“女”同学的name、sex和birthday
select sname as name,ssex as sex,sbirthday as birthday from student where ssex='女' unio
- 查询成绩高于学号为“109”、课程号为“3-105”的成绩的所有记录
select * from score where DEGREE>(select DEGREE from score where sno='109'and CNO='3-105');
- 查询和学号为108的同学同年出生的所有学生的Sno、Sname和Sbirthday列
Select sno,sname,sbirthday from student where year(sbirthday)=(select year(sbirthday) from student where sno=108);
- 查询和学号为108的同学同年出生的所有学生的Sno、Sname和Sbirthday列
Select sno,sname,sbirthday from student where year(sbirthday)=(select year(sbirthday) from student where sno=108);
- 查询Student表中不姓“王”的同学记录
Select * from student where sname not like '王%'
- 查询“张旭“教师任课的学生成绩
Select degree from score,teacher,course where score.cno=course.cno and course.tno=teacher.tno and teacher.tname='张旭';
- 查询选修某课程的同学人数多于5人的教师姓名
Select cno from score group by cno having count(*)>5;
Select tname from teacher as t inner join course as c
On t.tno=c.tno where cno in(Select cno from score group by cno having count(*)>5);
- 查询95033班和95031班全体学生的记录
select * from student where class='95033' or '95031';
- 查询出“计算机系“教师所教课程的成绩表
Select score.*from teacher as inner join course as con t.tno=c.cno inner join score as con c,cno=s.scno
- 查询选修编号为“3-105“课程且成绩至少高于选修编号为“3-245”的同学的Cno、Sno和Degree,并按Degree从高到低次序排序。
Select degree from score where cno=’3-105’
And degree>all(Select degree from score where cno=’3-245’)
- 查询所有姓李的同学的sno,sname,cno,degree
Select s.sno,sname,cno,degree from student as s inner join score as c no s.sno=c.sno where sname like ‘李%’;
- 查询成绩比该课程平均成绩低的同学的成绩表
Select * from score where degree<(select avg (degree)from score as s where cno=s.cno);
- 查询所有任课教师的Tname和Depart
select tname,depart from teacher where tno in (select tno from course where cno in (select distinct cno from score));
- 查询所有未讲课的教师的Tname和Depart
select tname,depart from teacher where tname not in( select distinct tname from teacher,course,score where teacher.tno=course.tno and course.cno=score.cno);
- 查询至少有2名男生的班号
select class from student where ssex='男' group by class having count(*)>1;
- 查询“男”教师及其所上的课程
select tname,cname from teacher ,course where tsex='男' and teacher.tno=course .tno;
- 查询和“李军”同性别并同班的同学Sname
select sname from student where ssex=(select ssex from student where sname='李军') and sname not in ('李军') and class =(select class from student where sname='李军');
出自:https://blog.csdn.net/Long_UP/article/details/106124087?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-9.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-9.channel_param
【MySQL】Select * From查询语句集合相关推荐
- MySQL的基本查询语句
MySQL的基本查询语句 一.数据准备 CREATE TABLE `customers` (`cust_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '顾客I ...
- mysql联表查询语句示例
mysql联表查询语句示例 ps:本人亲测,阿里云2核4G5M的服务器性价比很高,新用户一块多一天,老用户三块多一天,最高可以买三年,感兴趣的可以戳一下:阿里云折扣服务器 示例: "sele ...
- MySQL多表查询语句
MySQL多表查询语句 1.内连接查询 1.隐式内连接:使用where条件消除无用数据例子: --查询所有员工信息和对应的部门信息SELECT * FROM emp,dept WHERE emp.de ...
- mysql 在sql查询语句结果中,数字加千分逗号
mysql 在sql查询语句结果中,数字加千分逗号 FORMAT(X,D) 将number X设置为格式 '#,###,###.##', 以四舍五入的方式保留到小数点后D位, 而返回结果为一个字符串. ...
- mysql 数据库里查询语句中不等于的两种写法
mysql 数据库里查询语句中不等于的两种写法 ps:本人亲测,阿里云2核4G5M的服务器性价比很高,新用户一块多一天,老用户三块多一天,最高可以买三年,感兴趣的可以戳一下:阿里云折扣服务器 1.my ...
- mysql select符合查询_数据库select group by 和having语句 多表连接查询 复合查询
1.SELECT --group by 子句 group by子句按照指定的列column_name对表数据进行分组 group by 后面跟的列也叫分组特性列 使用group by后,能选择的列 ...
- mysql 伪表查询语句_MySQL数据库之select查询语句
select查询语句 语法 select [选项] 列名 [from 表名] [where 条件] [group by 分组] [order by 排序][having 条件] [limit 限制] ...
- mysql的高级查询语句
内容预知 1.本文前言 2. 高效查询方式 2.1 指定指字段进行查看 2.2 对字段进行去重查看 2.3 where条件查询 2.4 and 和 or 进行逻辑关系的增加 2.5 查询取值列表中 ...
- mysql执行非查询语句_iBatis执行非查询语句(CRUD,函数和过程)
insert into users(USERNAME,PASSWORD,AGE,MOBILE,EMAIL) values(#userName:VARCHAR#,#password:VARCHAR#,# ...
- mysql mysql的所有查询语句和聚合函数(整理一下,忘记了可以随时看看)
2019独角兽企业重金招聘Python工程师标准>>> 1. 查询所有字段 select * from 表名: 2. 查询自定字段 select 字段名 from 表名: 3. 查询 ...
最新文章
- 运行ORB-SLAM笔记_使用篇(二)
- 实现一个 能在O(1)时间复杂度 完成 Push、Pop、Min操作的 栈
- maven 加入第三方库_maven加载第三方jar不能加载
- Touchpad Synaptics 触摸板(中文) [zt]
- origin安装包_作图技巧|研究生需要会的20个Origin操作,作图又快又好看(二)...
- Bootstrap4+MySQL前后端综合实训-Day08-AM【多表查询sql语句、关联数据的假删除、自动增长主键的获取、栏目管理“数据编辑”按钮的实现】
- Android开发之品牌机型不同setMargins属性无效的bug
- 服务器禁止head 请求_编写下载服务器。 第四部分:有效地执行HEAD操作
- LeetCode 502. IPO(优先队列)
- C语言实现静态顺序表
- win 7 连接打印机
- 泛型类型(Generic Type)
- 计算机坏处英语,玩电脑的危害英语作文,沉迷电脑的危害英语作文!
- Selpg—Golang
- 基址变址寻址来实现暂存数据功能
- js页面跳转 和 js打开新窗口方法
- 有谁还在说入门大数据难?从spark开始带你起飞
- 基于sqlite3的利用数据库实现简单通讯录
- 58同城私有化:错过移动红利,吃流量老本,如何挽回崩塌的形象?
- Linux内核平台设备驱动模型platform_device和platform_driver框架
热门文章
- z-index在ios失效问题记录
- 不懂做计划,团队全拉垮?聪明的管理者都是这样做计划管理
- uoj 228 基础数据结构练习题
- 荣创出海:个人创业做亚马逊还能行吗?
- 60秒Dapp快讯|RAM突然暴涨1.52个GB;OK区块链工程院:已推出区块链介入疫苗供应链的技术方案
- IT业界正文 雷军力捧云服务:敢烧钱才能活下去
- 语音合成 - TTS-VUE 学习
- Android使用SVG小结
- 完美解决Cannot resolve com.github.wxpay:wxpay-sdk:3.0.9报错
- 细恐至微,那些与闰年有关的bug