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
what are defaults? Is there a column to which a default can't be bound? : Sql server database administration
How to handle error or exception in sql?
What is save transaction and save point?
What is the name of the Database which IBM mainframe uses?
What are cursors and when they are useful?
What is use of attribute hierarchy optimized state? : sql server analysis services, ssas
How you can get a list of all the table constraints in a database? : Sql server administration
Where can you add custom error messages to sql server?
Differentiate between truncate vs delete in mssql?
What is a bit datatype?
Explain how many types of relationship?
Write an sql query to sort a table according to the amounts in a row and find the second largest amount.
What is xml datatype?
how to determine the service pack currently installed on sql server? : Sql server database administration
How to transfer a table from one schema to another?