oracle的连接查询(内外连接)
来源:互联网 发布:linux命令强制删除文件 编辑:程序博客网 时间:2024/05/17 21:38
-- 连接查询的分类
-- 1.内连接:又叫做等值连接。
-- 2.外连接:又叫做左连接、右连接、全连接。
现已 commodity_table 和 store 这两张表 做示例;
store 表中的外键是 community_number,与之相关联的是commodity_table 表的主键 serial_number 。
例:-- 内连接(简写)
select a.name,b.store_name from commodity_table a,store b wherea.serial_number=b.commodity_number;
-- 内连接(完整的写法)
select a.name,b.store_name form from commodity_table ainner join store b on a.serial_number=b.commodity_number;
-- 外连接-左连接(以左表为基准,关联右表,关联上的数据直接显示,
-- 未关联上的则显示左表记录,右表记录为空值)
select * from commodity_table aleft join store b on a.serial_number=b.commodity_number;
--外连接-左连接的另一种简写方法
select * from commodity_table a,store bwhere a.serial_number=b.commodity_number(+);
-- 外连接-右连接(以右表为基准,关联左表,关联上的数据直接显示,
-- 未关联上的则显示右表记录,左表记录为空值)
select * from commodity_table a right join store bon a.serial_number=b.commodity_number;
--外连接-右连接的另一种简写方法
select * from commodity_table a,store b wherea.serial_number(+)=b.commodity_number;
-- 外连接-全连接
select * from commodity_table afull join store b on a.serial_number=b.commodity_number
order by serial_number;
-- 等价于 左连接跟右连接的集合
select * from commodity_table a left join store bon a.serial_number=b.commodity_number
union
select * from commodity_table aright join store b on a.serial_number=b.commodity_number;
0 0
- oracle的连接查询(内外连接)
- Oracle的内外连接
- 数据库查询内外连接
- Oracle SQL/92标准的关联查询(内外连接、交叉连接)
- sql内外连接查询的区别
- oracle 内外连接 join 总结
- Oracle笔记之内外连接
- SQL Server 查询的内外连接方式(亲自实践)
- Oracle的连接查询
- Oracle的连接查询
- 内外连接
- 内外连接
- 内外连接
- 内外连接
- 内外连接
- 内外连接
- SQL2000 数据库的内外连接
- 左右内外全交叉连接查询总结
- Linux学习之九(I/O重定向)
- Nginx学习之合并请求连接加速网站访问
- Problem : STL——集合运算
- 7个最佳的Java框架
- Spring的文件上传
- oracle的连接查询(内外连接)
- extjs4 combobox 多选与赋值
- 数据库基础知识~
- 使用云片API发送短信验证码
- Logstash实时同步mysql数据库至elastic
- 实施数据备份及云端迁移的七大理由
- ElasticSearch——nested(mapping,query,aggregation)
- [李景山php] php中call_user_func_array 的使用
- 基于ALTERA实现的闹钟工程