Mysql数据库_DML_多表连接.sql
来源:互联网 发布:剑三破军道姑捏脸数据 编辑:程序博客网 时间:2024/05/17 21:56
/*
//多表连接
*/
/*
//1.交叉连接/笛卡尔交集
*/
select count(*) from tb_emp;#17
select count(*) from tb_dept;#4
select * from tb_emp,tb_dept;#68=17*4;
select * from tb_emp cross join tb_dept; # --标准写法
/*
//2.内连接 连接条件就是主外键关联
*/
select * from tb_emp e,tb_dept d where e.deptno = d.deptno;
select * from tb_dept inner join tb_emp on tb_dept.deptno = tb_emp.deptno;
/*
//3.左外连接
左边的表为主表,坐标的表记录全部显示,如果没有找到记录则补NULL
*/
select * from tb_dept left join tb_emp on tb_dept.deptnp = tb_emp.deptno;
#oracle语法,左连接加号在右边
select * from t b_emp e,tb_dept d where e.deptno = d.deptno(+);
/*
//3.右外连接
右边的表为主表,坐标的表记录全部显示,如果没有找到记录则补NULL
*/
select * from tb_dept left join tb_emp on tb_dept.deptnp = tb_emp.deptno;
#oracle语法,左连接加号在右边
select * from t b_emp e,tb_dept d where e.deptno = d.deptno(+);
/*
//自连接
*/
select c.name '类别名',c2.name '父类别名'
from tb_course c,tb_course c2
where c.pid = c2.id;
//多表连接
*/
/*
//1.交叉连接/笛卡尔交集
*/
select count(*) from tb_emp;#17
select count(*) from tb_dept;#4
select * from tb_emp,tb_dept;#68=17*4;
select * from tb_emp cross join tb_dept; # --标准写法
/*
//2.内连接 连接条件就是主外键关联
*/
select * from tb_emp e,tb_dept d where e.deptno = d.deptno;
select * from tb_dept inner join tb_emp on tb_dept.deptno = tb_emp.deptno;
/*
//3.左外连接
左边的表为主表,坐标的表记录全部显示,如果没有找到记录则补NULL
*/
select * from tb_dept left join tb_emp on tb_dept.deptnp = tb_emp.deptno;
#oracle语法,左连接加号在右边
select * from t b_emp e,tb_dept d where e.deptno = d.deptno(+);
/*
//3.右外连接
右边的表为主表,坐标的表记录全部显示,如果没有找到记录则补NULL
*/
select * from tb_dept left join tb_emp on tb_dept.deptnp = tb_emp.deptno;
#oracle语法,左连接加号在右边
select * from t b_emp e,tb_dept d where e.deptno = d.deptno(+);
/*
//自连接
*/
select c.name '类别名',c2.name '父类别名'
from tb_course c,tb_course c2
where c.pid = c2.id;
0 0
- Mysql数据库_DML_多表连接.sql
- Mysql数据库_DML_常用函数.sql
- Mysql数据库_DML_子查询.sql
- sql数据库多表连接
- 数据库MySQL-----------多表连接
- SQL多表连接查询以及mysql数据库、sqlserver数据库常见不同点
- java连接mysql数据库 以及java连接sql server数据库
- Mysql数据库表连接
- Oracle SQL Developer 连接 Mysql 等数据库
- Oracle SQL Developer 连接 Mysql 等数据库
- Oracle SQL Developer 连接 Mysql 等数据库
- Oracle SQL Developer 连接 Mysql 等数据库
- Spark-SQL连接MySql关系型数据库
- sql developer如何连接mysql数据库
- python 连接sql server、mysql数据库
- C#连接MySql和Sql数据库
- SQl Server 数据库多表连接
- Sql Server 数据库 多表连接操作
- Mysql数据库_DML.sql
- 自定义view
- Hessian客户端
- cramfs文件系统识别nand坏块的解决方法
- Mysql数据库_DML_常用函数.sql
- Mysql数据库_DML_多表连接.sql
- 小黄人快跑安卓版 v2.0.2 免费手机版下载
- iOS第三方开源库的吐槽和备忘
- Mysql数据库_DML_子查询.sql
- leetcode整理的资料(第一篇)
- QQ悬浮客服跟其他JQ冲突的解决办法
- 词法分析
- Mysql数据库_索引.sql
- student.sql