Javatpoint Logo
Javatpoint Logo

SQL Cross Join

When each row of first table is combined with each row from the second table, known as Cartesian join or cross join. In general words we can say that SQL CROSS JOIN returns the Cartesian product of the sets of rows from the joined table.

We can specify a CROSS JOIN in two ways:

  1. Using the JOIN syntax.
  2. the table in the FROM clause without using a WHERE clause.

SYNTAX of SQL Cross Join

Let us take an example of two tables,

Table1 - MatchScore

PlayerDepartment_idGoals
Franklin12
Alan13
Priyanka22
Rajesh35

Table2 - Departments

Department_idDepartment_name
1IT
2HR
3Marketing

SQL Statement:

After executing this query , you will find the following result:

PlayerDepartment_idGoalsDepatment_idDepartment_name
Franklin121IT
Alan131IT
Priyanka221IT
Rajesh351IT
Franklin122HR
Alan132HR
Priyanka222HR
Rajesh352HR
Franklin123Marketing
Alan133Marketing
Priyanka223Marketing
Rajesh353Marketing
Next TopicSQL Primary Key




Please Share

facebook twitter google plus pinterest tumbler

Learn Latest Tutorials