Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (55.6k points)
edited by

Can anyone tell me how to join two tables without a common column in SQL?

1 Answer

0 votes
by (119k points)
edited by

We can use the Cartesian product, union, and cross-product to join two tables without a common column.

Cartesian product means it matches all the rows of table A with all the rows of table B. Here are the syntax to do a Cartesian product for two tables:

SELECT * FROM tableA, tableB;

Union returns the combination of result sets of all the SELECT statements. The following is the query to use Union operator:

SELECT column_list FROM tableA

UNION

SELECT column_list FROM tableB

Here is the syntax to use CROSS JOIN to combine two tables when a particular condition is met”

SELECT tableA.Column1, tableB.Column1

FROM tableA

CROSS JOIN tableB

WHERE tableB.Column1 = ‘value’;

You can go through this SQL tutorial by Intellipaat to learn more such SQL tips and tricks.

You can learn in-depth about SQL statements, queries and become proficient in SQL queries by enrolling in our industry-recognized SQL training.

Related questions

0 votes
1 answer
asked Apr 20, 2020 in SQL by Sudhir_1997 (55.6k points)
0 votes
1 answer
asked Jan 7, 2021 in SQL by Appu (6.1k points)
0 votes
1 answer
0 votes
1 answer
asked Apr 30, 2020 in SQL by Sudhir_1997 (55.6k points)
0 votes
1 answer

Browse Categories

...