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.