Codechef4u is a community for computer professionals,by computer professionals,just like you; who loves sharing and helping each others,Join them
Share your post

Cross join

Cross join:

A cross joins that produces Cartesian product of the tables that are involved in the join. The size of a Cartesian product is the number of the rows in the first table multiplied by the number of rows in the second table like this. The size of a Cartesian product result set is the number of rows in the first table multiplied by the number of rows in the second table.

Syntax:

SELECT
column_name(s)
FROM Table1 (Left Side Table)
CROSS JOIN Table2 (Right Side Table);

 

Example:

SELECT ProductName AS [Product Name]
,UnitPrice AS [Price]
,CategoryName AS [Product Category],ImagePath AS [Image]
 FROM Products P
CROSS JOIN Categories C

Cross join t-sql query will return result (Products table 7 rows * Categories table 6 rows =42 rows)


You can write a query like this also:

--Below query also returns same data
SELECT ProductName AS [Product Name]
,UnitPrice AS [Price]
,CategoryName AS [Product Category],ImagePath AS [Image]
 FROM Products P , Categories C 

Invalid entry,please enter valid data.

Loading