联接两个没有关系的表 [英] Join two tables without relationship

查看:99
本文介绍了联接两个没有关系的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想 JOIN 两个表没有关系。两个表的RowCount和DataType都不相同...如果一个表的行比另一个表的行少,我不想重复任何行

I want to JOIN two tables without relationship. Both tables have a different RowCount and DataType... I don't want to repeat any rows if one table has less rows than the other

TableA
A
B
C

TableB
4
2

所需结果:

TableA | TableB
A      |     4
B      |     2
C      |


推荐答案

您可以使用全部合并或使用 row_number()

select col1, col2
from (select a.col1, row_number() over (order by col1) as seqnum
      from a
     ) a full outer join
     (select b.col2, row_number() over (order by col2) as seqnum
      from b
     ) b
     on a.seqnum = b.seqnum;

这篇关于联接两个没有关系的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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