Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
jcb267
Constraint Violating Yak Guru
291 Posts |
Posted - 2011-01-10 : 12:32:26
|
| Hi - I need data from 3 different tables, I am making multiple joins between the tables. This is what I have thus far, it is running but seems to be very inefficient.dw.dbo.PremiumBilling pb inner join dw.dbo.sponsordemographics sd on pb.sponsorid = sd.sponsorid, dw.dbo.PremiumBilling pb2 inner join dw.dbo.sponsorpolicy sp on pb2.policynumber = sp.policynumberIs this even correct? What can I do to speed it up?? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-01-10 : 12:42:21
|
its not correct as it has a cross join in between. probably you meant this?...dw.dbo.PremiumBilling pb inner join dw.dbo.sponsordemographics sd on pb.sponsorid = sd.sponsoridinner join dw.dbo.sponsorpolicy sp on pb.policynumber = sp.policynumber ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
jcb267
Constraint Violating Yak Guru
291 Posts |
Posted - 2011-01-10 : 12:48:17
|
Yes, that is what I meant. Thanks!!quote: Originally posted by visakh16 its not correct as it has a cross join in between. probably you meant this?...dw.dbo.PremiumBilling pb inner join dw.dbo.sponsordemographics sd on pb.sponsorid = sd.sponsoridinner join dw.dbo.sponsorpolicy sp on pb.policynumber = sp.policynumber ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-01-10 : 12:50:21
|
| welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
jcb267
Constraint Violating Yak Guru
291 Posts |
Posted - 2011-01-10 : 12:51:42
|
what is a cross join? quote: Originally posted by visakh16 its not correct as it has a cross join in between. probably you meant this?...dw.dbo.PremiumBilling pb inner join dw.dbo.sponsordemographics sd on pb.sponsorid = sd.sponsoridinner join dw.dbo.sponsorpolicy sp on pb.policynumber = sp.policynumber ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-01-10 : 13:03:03
|
| cross join is equivalent to cartesian product. ie it returns all possible combinations of resultset from two queries------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|