Redian新闻
>
难。想了一天了。大牛请进。
avatar
难。想了一天了。大牛请进。# Database - 数据库
P*M
1
How to make the table t3 from data from t1 and t2?
table: t1
+------+------+
| a | b |
+------+------+
| 1 | a |
| 2 | aa |
+------+------+
table:t2;
+------+------+
| a | b |
+------+------+
| 1 | b |
| 3 | bb |
+------+------+
t3: summary table
+------+------+-------+
| a | b1 |b2 |
+------+------+-------+
| 1 | a |b |
| 2 | aa |null |
| 3 | null |bb |
+------+------+-------+
where b1 corresponding to a.[b]
b2 corresponding to
avatar
a*c
2
I would try this in Oracle.
Select temp.a, t1.b, t2.b
from t1,
t2,
(select a from t1
union
select a from t2) temp
where temp.a = t1.a(+)
and temp.a = t2.a(+)

【在 P**M 的大作中提到】
: How to make the table t3 from data from t1 and t2?
: table: t1
: +------+------+
: | a | b |
: +------+------+
: | 1 | a |
: | 2 | aa |
: +------+------+
: table:t2;
: +------+------+

avatar
c*t
3
the result is a full outer join, but you only did a left join.

【在 P**M 的大作中提到】
: How to make the table t3 from data from t1 and t2?
: table: t1
: +------+------+
: | a | b |
: +------+------+
: | 1 | a |
: | 2 | aa |
: +------+------+
: table:t2;
: +------+------+

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。