Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

cartesian product on two tables

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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?

>Solution :

Use this:

select A.table_name, B.column_name from A, B;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading