1. Back To Blog

Are full outer join and Cross join are same? ( SQL Server interview questions with answers)

No, they are not. Full outer join returns common records in both the tables + uncommon records for left table + uncommon records from right table. Where as in Cross Join we will get Cartesian product, that means every record of left table will be combined with every row in right table and result was returned back.

 

Example:

Table 1

Column 1

Column2

A

X

B

Y

C

Z

D

W

Table 2

Column2

Column3

X

XName

Y

YName

P

PName

O

OName

 

Full Outer Join
Select * from Tabl1 inner join Tabl1 Full outer join Tabl2 on Table1.X Full outer join Table2.

Column 1

Column2

Column2

Column3

A

X

X

XName

B

Y

Y

YName

C

Z

NULL

NULL

D

W

NULL

NULL

NULL

NULL

P

PName

NULL

NULL

O

OName

 

 

Cross join
Select * from Table1, Table2

Column 1

Column2

Column2

Column3

A

X

X

XName

A

X

Y

YName

A

X

P

PName

A

X

O

OName

B

Y

X

XName

B

Y

Y

YName

B

Y

P

PName

B

Y

O

OName

C

Z

X

XName

C

Z

Y

YName

C

Z

P

PName

C

Z

O

OName

D

W

X

XName

D

W

Y

YName

D

W

P

PName

D

W

O

OName

 


Below is a nice SQL Server interview questions with answer on inner join , left join and right join.

 

 

For further references please visit www.questpond.com which has more than 600 videos on .Net and SQL Server interview questions with answers.

Shiv Prasad Koirala

Visit us @ www.questpond.com or call us at 022-66752917... read more

We are on Social