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
What is the difference between inner join and equi join?
What is the data tier application?
What are the main sources of data?
Can you leave a union at any time?
What is a matrix in ssrs?
Explain what is “asynchronous” communication in sql server service broker?
What is the stored procedure?
Explain system scalar functions?
Define union, union all, minus, intersect?
How is sql server used?
Where does the copy job runs in the log shipping primary or secondary? : sql server database administration
Can you tell me some of the common replication dmv's and their use? : sql server replication
How many types of triggers in sql server?
Does dbcc checkdb requires db to be in single_user mode? : sql server database administration
What is transaction server distributed transaction?