Friday, March 30, 2012

Multiple joins in SQL Server

Hi I have a requirement where in i haev to convert the SQL from Oracle
to the one which will run on the SQL server.
in the Oracle Query i am doing multiple joins, between some 13 tables.
and some of these joins are inner joins and some are Left outer joins.
table1 inner joined with table 2
table2 inner join with table3
table2 inner join with table4
table2 left join with table5
table5 left jin with table6
table6 left jin with table7
table7 left jin with table8
table8 left jin with table9
Any idea how to achieve this'
Tia
naren"narendra vuradi" <nvuradi@.gmail.com> wrote in message
news:aad31742-b563-4da4-8a37-4be71ebf81c7@.e23g2000prf.googlegroups.com...
> Hi I have a requirement where in i haev to convert the SQL from Oracle
> to the one which will run on the SQL server.
> in the Oracle Query i am doing multiple joins, between some 13 tables.
> and some of these joins are inner joins and some are Left outer joins.
> table1 inner joined with table 2
> table2 inner join with table3
> table2 inner join with table4
> table2 left join with table5
> table5 left jin with table6
> table6 left jin with table7
> table7 left jin with table8
> table8 left jin with table9
> Any idea how to achieve this'
> Tia
> naren
Using standard SQL (rather than the proprietary Oracle syntax) it should
look pretty close to the way you wrote it:
SELECT ... /* columns */
FROM table1
INNER JOIN table2
ON table1.col = table2.col
INNER JOIN table3
ON table2.col = table3.col
INNER JOIN table4
ON table2.col = table4.col
LEFT OUTER JOIN table5
ON table2.col = table5.col
LEFT OUTER JOIN table6
ON table5.col = table6.col
LEFT OUTER JOIN table7
ON table6.col = table7.col
LEFT OUTER JOIN table8
ON table7.col = table8.col
LEFT OUTER JOIN table9
ON table8.col = table9.col ;
--
David Portas|||Hi
In addition to David's suggestion , I'd note you that JOIN 13 tables does
not look good in terms of database/application design as well as performance
"narendra vuradi" <nvuradi@.gmail.com> wrote in message
news:aad31742-b563-4da4-8a37-4be71ebf81c7@.e23g2000prf.googlegroups.com...
> Hi I have a requirement where in i haev to convert the SQL from Oracle
> to the one which will run on the SQL server.
> in the Oracle Query i am doing multiple joins, between some 13 tables.
> and some of these joins are inner joins and some are Left outer joins.
> table1 inner joined with table 2
> table2 inner join with table3
> table2 inner join with table4
> table2 left join with table5
> table5 left jin with table6
> table6 left jin with table7
> table7 left jin with table8
> table8 left jin with table9
> Any idea how to achieve this'
> Tia
> naren

No comments:

Post a Comment