union合并表与内连接
来源:互联网 发布:有淘宝卖家手机版本 编辑:程序博客网 时间:2024/06/08 17:24
union合并表
union合并两个表的学生信息,消除重复项
select *from studentunion select *from student02
union all 合并两个表的学生信息,不消除重复项
select *from studentunion all select *from student02
将两张表合并的结果集插入在一张新表中
select name,age,sex,address into student_unionfrom student union all select name,age,sex,address from student02
inner join内连接的使用
创建学生成绩表
create table grade(ksid int not null,csid int not null,fs int)go
向学生成绩表插入信息(学生ID,测试ID,分数)
insert into grade(ksid,csid,fs)values('7','71','70'),('8','81','80'),('9','91','90'),('13','913','101')go
查询学生成绩表
select * from grade
两表(学生信息表和学生成绩表)内连接,查询学生信息及成绩
select st.name,st.age,st.sex,st.address,gr.fsfrom student stinner join grade gron st.id = gr.ksid
创建学生课程表
create table course(kcid int not null,kcmc char(8))go
向课程表插入信息(课程ID,课程名字)
insert into course(kcid,kcmc) values('7','语文'),('8','计算机'),('9','数学'),('13','外语')go
查询学生课程表
select *from course
内连接查询三张表(学生信息表,成绩表,和课程表)
select st.name,gr.fs,co.kcmcfrom student stinner join grade gr on st.id = gr.ksidinner join course co on gr.ksid = co.kcid
0 0
- union合并表与内连接
- mysql中union,左连接,右连接,与内连接
- Mysql左连接left join on与右连接 right join on,内连接union区别
- 外连接与union
- 左连接、右连接、内连接、外连接、union连接
- union all 向上合并表
- MySQL左连接,右连接,内连接,union
- mysql 左连接 右连接 内连接 union
- union 与 order by 合并使用
- UNION JOIN 连接表
- Oracle SQL基础之(二) [联合查询、union、子查询、外、内连接、复制表]
- list合并与连接
- 两个 DataTable 合并 inner join 内连接
- union来合并两个表的列
- 内连接与外连接
- 外连接与内连接
- 内连接与外连接
- 内连接与外连接
- PAT算法笔记(一)————A+B和C
- 404. Sum of Left Leaves
- 深度了解Android 7.0,你准备好了吗?
- Ubuntu 12.04后无法安装 ia32-libs 的解决方法
- SQL_SERVER 2012 安装报告
- union合并表与内连接
- JavaScript的一些基本知识 -- 字符串
- Codeforces 778B. Weird Rounding
- 2238: Mst
- Python2.7下 epd free 安装pandas可能会出现的问题
- cocos2d-js动作的连续
- 【数据结构和算法】全面剖析树的各类遍历方法
- 这些年,我身边的那些人和事
- Web前端攻击方式及防御措施