September 28, 2011 at 12:00 pm
Hello All experts,
I have requirment to run the queries against three tables with left outer join,
it has give all the all rows from a table and plus matching rows from other tables.
I hope you understand this question.
i am new to the queries
any help highly appreciated.
September 28, 2011 at 12:05 pm
That is what a left join does...http://msdn.microsoft.com/en-us/library/ms191472.aspx
select [Columns]
from MyTable
left join Table2 on ??
left join Table 3 on ??
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
September 28, 2011 at 12:19 pm
rashid_alavi (9/28/2011)
Hello All experts,I have requirment to run the queries against three tables with left outer join,
it has give all the all rows from a table and plus matching rows from other tables.
I hope you understand this question.
i am new to the queries
any help highly appreciated.
So it would probably look something like this:
select * from table1 t1
left join table2 t2 on t1.id = t2.id
left join table3 t3 on t1.id = t3.id
You would need to replace table1, table2 and table3 with your tables names. You would also need to replace the id file with whatever name your table key field is to link to the other tables.
Ben
September 29, 2011 at 2:43 am
Thanks a lot, it worked
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply