TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

SQL CROSS JOIN

SQL cross join query with sql, tutorial, examples, insert, update, delete, select, join, database, table, join

<< Back to SQL

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

SELECT * FROM [TABLE1] CROSS JOIN [TABLE2]
OR
SELECT * FROM [ TABLE1] , [TABLE2]

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:

SELECT * FROM MatchScore CROSS JOIN Departments

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




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf