In this article, we will learn how to use the CROSS JOIN keyword in SQL.
The CROSS JOIN keyword is used to combine each row of the first table with each row from the second table, also known as CARTESIAN JOIN.
In general words, we can say that the CROSS JOIN keyword is used to select the Cartesian product of the sets of rows from the joined table.
We can specify a CROSS JOIN in two ways:
- Using the JOIN syntax.
Syntax
SELECT column_name(s) FROM TABLE_NAME1 CROSS JOIN TABLE_NAME2;
Example
SELECT Viewers.*, Article.* FROM Viewers CROSS JOIN Article;
- The table in the FROM clause without using a WHERE clause, which is known as SELF JOIN.
Syntax
SELECT column_name(s) FROM TABLE_NAME1, TABLE_NAME2;
Example
SELECT Viewers.*, Article.* FROM Viewers, Article;
Also, check How To Use FULL OUTER JOIN Keyword In SQL