多个加入如何工作?它的工作顺序是什么? [英] How multiple join work? In What sequence it works?

查看:75
本文介绍了多个加入如何工作?它的工作顺序是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有4个表说: -

1. A

2. B

3. C

4. D

Suppose I have 4 Tables say:-
1. A
2. B
3. C
4. D

create table A
(id int,
sal int);

insert into A  values(1,100);
insert into A  values(2,200);

create table B
(id int,
sal int);

insert into B  values(1,100);

create table C
(id int,
sal int);

insert into C  values(1,100);
insert into C  values(2,200);

create table D
(id int,
sal int);

insert into D  values(1,100);
insert into D  values(2,200);



和我执行以下查询说: -




and I execute following query say: -

select a.id as AID,a.sal as Asal,b.id as BID ,b.sal as Bsal , 
c.id as CID , c.sal as CSal ,d.id as Did , d.sal
from A as a,B as b , C as c ,D as d;



如何4表的笛卡尔积是否有效?


How does the cartesian product of 4 table works??

推荐答案

笛卡儿积是一种数学运算,它从多个集合中返回集合(或产品集)。也就是说,对于集合A和B,笛卡尔乘积A×B是所有有序对(a,b)的集合,其中a∈A和b∈B。

A Cartesian product is a mathematical operation which returns a set (or product set) from multiple sets. That is, for sets A and B, the Cartesian product A × B is the set of all ordered pairs (a, b) where a ∈ A and b ∈ B.
A = {1,2}; B = {3,4} 
A × B = {1,2} × {3,4} = {(1,3), (1,4), (2,3), (2,4)}





在您的案例集中,其笛卡尔积如下。





In your case set and its cartesian product will be as follows.

A = {(1,100), (2,200)}
B = {(1,100)}
C = {(1,100), (2,200)}
D = {(1,100), (2,200)}

1	100	1	100	1	100	1	100
1	100	1	100	1	100	2	200
1	100	1	100	2	200	1	100
1	100	1	100	2	200	2	200
2	200	1	100	1	100	1	100
2	200	1	100	1	100	2	200
2	200	1	100	2	200	1	100
2	200	1	100	2	200	2	200


这篇关于多个加入如何工作?它的工作顺序是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆