Join 3 tables (table1, table2 & table3) in a single query.

Inner join should be applied for table1 & table 2 and left
outer join for table1 & table3 where table2.dept is ABC

Answer Posted / sumit m.

Although the above answer is correct. I am preferring
paranthesis in the answer, something like below:

There are 2 forms of the query for the answer:

SELECT *
FROM (table t1 INNER JOIN table2 t2 ON t1.col = t2.col AND
t2.dept = 'ABC')
LEFT JOIN table t3 ON t1.col = t3.col

OR

SELECT *
FROM (table t1 INNER JOIN (SELECT * FROM table2 WHERE dept
= 'ABC') t2 ON t1.col = t2.col)
LEFT JOIN table t3 ON t1.col = t3.col

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between composite index and covering index?

605


Why should we go for stored procedures? Why not direct queries?

655


How to defragment indexes with alter index ... Reorganize?

666


What are the advantages of using stored procedures in sql server?

587


Explain the use of containers in ssis?

605






How check triggers in sql server?

587


Define normalisation?

775


What is star, snowflake and star flake schema? : sql server analysis services, ssas

743


What is sleeping status in sql server?

606


Can you explain what is indexed view? How to create it?

617


What is the difference between a function and a stored procedure?

659


Describe different Processing Modes offered by SSRS?

187


how to create “alternate row colour”?

115


How to optimize stored procedures in sql server?

722


What is constraints and its types?

574