两张桌子上的笛卡尔产品
我正在尝试创建一个表名称和列名的结果集。表AI中有表名的列表,在表BI中具有列名列表。每个表格应具有列的完整列表。因此:
- 表A
table_name |
---|
table1 |
表2 |
- 表B
列列 |
---|
1列 |
2 |
列3 |
我想要的结果是:
table_name | column_name |
---|---|
table1 | column1 column1 |
column1 | column2 |
table2 | table2 |
column2 | table2 |
table2 | 列 |
table2 | column2 column2 column2 column3 |
所以我有 选择
select
table_name
column_name
from
A
full outer join
B
on
A.TABLE_NAME = B.COLUMN_NAME
哪个给我:
table_name | column_name |
---|---|
table1 | |
table2 | |
column1 column2 | |
column2 | |
column3 |
关闭,但没有雪茄! 我该如何得到答案?
I'm trying to create a result set of table names and column names. In table A I have the list of table names and in Table B I have the list of column names. Each table should have the full list of columns. So:
- Table A
table_name |
---|
Table1 |
Table2 |
- Table B
column_name |
---|
Column1 |
Column2 |
Column3 |
The result I want is:
table_name | column_name |
---|---|
Table1 | Column1 |
Table1 | Column2 |
Table1 | Column3 |
Table2 | Column1 |
Table2 | Column2 |
Table2 | Column3 |
So I have
select
select
table_name
column_name
from
A
full outer join
B
on
A.TABLE_NAME = B.COLUMN_NAME
Which gives me:
table_name | column_name |
---|---|
Table1 | |
Table2 | |
Column1 | |
Column2 | |
Column3 |
Close, but no cigar!
How can I get my answer please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用以下方式:
Use this:
如果您的桌子不太大,请尝试一下:
try this if your tables are not too big: