CROSS
CROSS in SQL is used to perform cross join operation which produces the Cartesian product of the rows in two or more tables. It does not require a condition to join. Each row from the first table is combined with each row from the second table resulting in a large number of combinations.
Example
Output
Explanation
The given SQL query demonstrates the use of the CROSS JOIN
clause. CROSS JOIN
returns the Cartesian product of rows from the tables involved in the join. The resulting table will have rows that combine each row from the first table with each row from the second table. The LIMIT 5
clause limits the result to the first five records.
Example
Output
Explanation
CROSS JOIN returns the Cartesian product of rows from the tables in the join. In this example, every row from table1 is combined with every row from table2. There are 3 rows in table1 and 2 rows in table2, so the result is a table with 6 rows.
Example
Output
Explanation
The CROSS JOIN
in SQL Server returns the cartesian product of the sets of records from the two or more joined tables. This means that it will return all the possible combinations of rows from the joined tables. In this example, each row from TableA is combined with each row from TableB.
Example
Output
Explanation
CROSS JOIN returns the Cartesian product of rows from tables in the join. In this example, it returns every combination of records from Orders
and Customers
.