sql多表查询

mysql> drop view if exists v_student;

mysql> select * from score;

mysql> select * from student limit 2,4;

mysql> select * from student

-> where department='英语系' or department='中文系';

mysql> select count(1) from student

-> group by department;

mysql> select max(grade),c_name '最高分' from score

-> group by c_name;

mysql> select c_name,grade from student join score on student.id=score.stu_id

-> where name='李广昌';

mysql> select student.*,score.* from student join score on student.id

-> =score.stu_id;

mysql> select name,sum(grade) '总成绩' from student join score on student.id=score.stu_id

-> group by name;

mysql> select department,round(avg(grade),2) '总成绩' from student join score on student.id=

score.stu_id

-> group by department;

mysql> select student.*,c_name,grade from student join score on student.id=

-> score.stu_id

-> where c_name='计算机' and grade<95;

mysql> select student.*,c_name,grade from student join score on student.id=

-> score.stu_id

-> where c_name='计算机'

-> order by grade desc;

mysql> select id from student union select stu_id from score;

mysql> select name,department,c_name,grade from student join score on student.id=score.stu_id

-> where name like '张%' or name like '王%';

mysql> select name,year(now())-birth '年龄',c_name,grade from student join score on student.

id=score.stu_id

-> where address like '湖南%';

相关推荐
猿小喵7 分钟前
DBA之路,始于足下
数据库·dba
tyler_download16 分钟前
golang 实现比特币内核:实现基于椭圆曲线的数字签名和验证
开发语言·数据库·golang
weixin_4493108442 分钟前
高效集成:聚水潭采购数据同步到MySQL
android·数据库·mysql
floret*44 分钟前
HiveSQL面试题
hive·sql
Cachel wood2 小时前
Github配置ssh key原理及操作步骤
运维·开发语言·数据库·windows·postgresql·ssh·github
standxy2 小时前
如何将钉钉新收款单数据高效集成到MySQL
数据库·mysql·钉钉
zybsjn2 小时前
数据库索引创建的最佳实践:规范与优化指南
sql
Narutolxy3 小时前
MySQL 权限困境:从权限丢失到权限重生的完整解决方案20241108
数据库·mysql
Venchill3 小时前
安装和卸载Mysql(压缩版)
数据库·mysql
Humbunklung3 小时前
一种EF(EntityFramework) MySQL修改表名去掉dbo前缀的方法
数据库·mysql·c#