Advertisement

SQL常见的几种连接查询解析

阅读量:

一、类型
1、内联结(join或inner join)
分为两种类型:显式类型和隐式类型。返回满足特定连接条件并符合查询要求的数据行。(所谓链接表即为数据库在执行查询时生成的临时结果集)。
语句1:隐式类型的内联结未使用inner join关键字,在这种情况下所生成的结果集等于两个原始数据集合的笛卡尔积。

选取订单中的订单ID、订单编号以及客户ID和客户名称,并来自客户表和订单表组合查询。

该过程通常被称为内连接,并通过使用inner join实现。具体而言,在这种情况下生成的中间表是两个原始表在满足特定条件后进行笛卡尔积运算的结果。

Retrieve the order details including order number, customer ID, and customer name by joining the orders table with the customers table on customer ID where applicable. The SQL query performs an inner join operation between tables orders and customers based on matching customer IDs.

2、外连接(outer join)

全部评论 (0)

还没有任何评论哟~