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 '湖南%';

相关推荐
数据和云6 分钟前
从Databricks和Supabase看AI时代的中国数据库启示
数据库·人工智能
我科绝伦(Huanhuan Zhou)6 分钟前
Oracle ADRCI工具全面使用指南:从基础到故障诊断实战
数据库·oracle
数据库生产实战9 分钟前
Oracle LOB使用入门和简单使用,提供学习用的测试用例!
数据库·学习·oracle
武子康15 分钟前
Java-144 深入浅出 MongoDB BSON详解:MongoDB核心存储格式与JSON的区别与应用场景
java·开发语言·数据库·mongodb·性能优化·json·bjson
Raymond运维30 分钟前
MySQL包安装 -- SUSE系列(SUSE资源库安装MySQL)
linux·运维·数据库·mysql
高山上有一只小老虎37 分钟前
如何在DBeaver中配置高斯数据库的连接
数据库
云飞云共享云桌面39 分钟前
东莞精密机械制造工厂如何10个SolidWorks共用一台服务器资源
java·运维·服务器·网络·数据库·电脑·制造
ActionTech1 小时前
2025 年 9 月《大模型 SQL 能力排行榜》发布,新增 Kimi K2 最新版测评!
数据库·sql·ai·oracle
lang201509282 小时前
掌握MyBatis Java API:高效操作数据库
java·数据库·mybatis
Mr.wangh2 小时前
Redis作为分布式锁
数据库·redis·分布式