explain different types of jions with examples briefly?

Answer Posted / dinesh .

16)Join
Table1:Record
1 a
2 b
3 b
4 b
4 c
Table2:Record1
1 a 2
2 b 2
3 c 24
5 f 2
8 g 2
10 j NULL
Inner Join:
Qry1:select record_name,recordcount from record inner join
record1 on
record.record_id=record1.record_code
Result:
a 2
b 2
b 24
qry2:select p.record_name,q.recordcount from record p,
record1 q where p.record_id=q.record_code
Result:
a 2
b 2
b 24
Left Join
qry3:select record_name,recordcount from record left join
record1 on
record.record_id=record1.record_code
Result:
a 2
b 2
b 24
b NULL
c NULL
Right Join
qry4:select record_name,recordcount from record right join
record1 on
record.record_id=record1.record_code
Result:
a 2
b 2
b 24
NULL 2
NULL 2
NULL NULL
Left Outer Join
qry5:select record_name,recordcount from record left outer
join record1 on
record.record_id=record1.record_code
Result:
a 2
b 2
b 24
b NULL
c NULL
Right Outer Join
qry6:select record_name,recordcount from record right outer
join record1 on
record.record_id=record1.record_code
Result:
a 2
b 2
b 24
NULL 2
NULL 2
NULL NULL
Full Outer Join
qry7:select record_name,recordcount from record full outer
join record1 on
record.record_id=record1.record_code
Result:
a 2
b 2
b 24
b NULL
c NULL
NULL 2
NULL 2
NULL NULL

"Their is No Left Inner Join,Right Inner Join in SQL Server

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the recursive stored procedure in sql server?

704


Why you need indexing? Where that is stored and what you mean by schema object? For what purpose we are using view?

671


Tell me what is use of except clause? How it differs from not in clause?

699


what method you can use to reduce the overhead of Reporting Services data sources?

200


What are the purposes of floor and sign functions?

729






What is key attribute?

697


What are click through reports?

118


After removing a table from database, what other related objects have to be dropped explicitly?

789


what is a correlated sub-query? : Sql server database administration

672


What is blocking and how would you troubleshoot it? : sql server database administration

763


What is the difference between cartesian product and cross join?

635


What is row_number()?

769


Which tcl commands are available on the sql server?

769


define and explain the differences between clustered and non-clustered indexes.

818


Is there any performance difference between if exists (select null from table) and if exists (select 1 from table)?

691