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 are defaults? Is there a column to which a default can't be bound? : Sql server database administration

616


How to handle error or exception in sql?

527


What is save transaction and save point?

622


What is the name of the Database which IBM mainframe uses?

536


What are cursors and when they are useful?

574






What is use of attribute hierarchy optimized state? : sql server analysis services, ssas

585


How you can get a list of all the table constraints in a database? : Sql server administration

511


Where can you add custom error messages to sql server?

579


Differentiate between truncate vs delete in mssql?

523


What is a bit datatype?

560


Explain how many types of relationship?

571


Write an sql query to sort a table according to the amounts in a row and find the second largest amount.

564


What is xml datatype?

650


how to determine the service pack currently installed on sql server? : Sql server database administration

563


How to transfer a table from one schema to another?

558