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
Answers were Sorted based on User's Feedback
Answer / dhanasekaran
select *
from table1 t1
inner join table2 t2 on t1.key = t2.key
left outer join table3 t3 on t1.key = t3.key
where t2.dept ='ABC'
Is This Answer Correct ? | 11 Yes | 0 No |
Answer / 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 |
what is a join? : Sql server database administration
What is attribute? : sql server analysis services, ssas
Explain what is the difference between union and union all?
What are difference between Cluster index and Non-Cluster index?
How to disable a login name in ms sql server?
How to run sql server 2005 books online on your local system?
How to copy the tables, schema and views from one sql server to another?
Explain what are the restrictions while creating batches in sql server?
how can u get last observation in an unknown dataset ?
Can we linked SharePoint to a SQL database?
0 Answers Sans Pareil IT Services,
If you want to send some data from access database to sql server database. What are different component of ssis will you use?
What are differences in between sql server 2012 and sql server 2016?