因此,关系为R(B, C, D)
,其值为(3, 1, 9 ), (3, 1, 6), (7, 9, 6), (3, 4, 3)
。
此查询将如何工作?
Select *
from (select B from R) as T1
natural join (select b, c, d from R) as T2.
我不允许对其进行计算。我继续得到关系R,一次又一次?我不明白,因为自然联接的目的是使值与同一列对齐(或至少我不了解),但是答案是有10个元组。我只有3个?我不明白我要去哪里错了。
您是否在结果集中得到10行?
drop table if exists t;
create table t
(b int,c int,d int);
insert into t values (3, 1, 9 ), (3, 1, 6), (7, 9, 6), (3, 4, 3);
Select *
from (select B from t) as T1
natural join (select b, c, d from t) as T2;
+------+------+------+
| B | c | d |
+------+------+------+
| 3 | 1 | 9 |
| 3 | 1 | 9 |
| 3 | 1 | 9 |
| 3 | 1 | 6 |
| 3 | 1 | 6 |
| 3 | 1 | 6 |
| 7 | 9 | 6 |
| 3 | 4 | 3 |
| 3 | 4 | 3 |
| 3 | 4 | 3 |
+------+------+------+
10 rows in set (0.00 sec)