# Cartesian products of two sets in Mathematics and how it is related to Cross Join in Sql server ?

Today i want to discuss the Cartesian products of two sets in Mathematics and how it is related to Cross Join in SQL-Server. This is the article i want to explain here with mathematical example and sql server query with Code snippets

Today i want to introduce the Cartesian products of two sets in Mathematics and how it is related to Cross Join of two tables in Structured Query Language (SQL - SERVER). This is the article i want to explain here in this.

Let us say A and B are two Disjoint sets say A has a set of pairs A= {3,4}; and B = {4,5} it will result with all ordered pairs.

what will be the Cartesian products of these two Disjoint sets

If we have done Cross Join between A * B

A × B = {3,4} × {4,5} = {(3,4), (3,5), (4,4), (4,5)}

B × A = {4,5} × {3,4} = {(4,3), (4,4), (5,3), (5,4)}

A = B = {4,4}** Cross Join between two tables : **

Tab1e : 1 ColName1Students

Table :2 ColName2Students

Select * from ColName1Students Cross Join ColName2Students

Select * from ColName1Students , ColName2Students

ColName1Students Table Contains

StudName

Bhushan

Srirama

rakesh

ColName2Students

studName

ravi

raj

ram

Resultset of the two tables is....

Bhushan

srirma

ravi

raj

ram

rakesh

**Note :**

When you apply cross join between two tables they need to have same cordial of Columns and same column names.

Computer science is a branch in Mathematics (Tree) (Many people may disagree with this and dislike this but there are many proofs and evidences as the above).Many of the Relations,functions, Sets even Group theory and Ring Theory like many a Theories are used in Databases and Programming Languages. From the above example it is quite evident that the Cartesian Product of two Sets is equal to Cross Join of two tables.

GoldPoints : 4