renee35
MIS
- Jan 30, 2007
- 199
I need some help with trying to make these table joins work. What I have is list of joins, but the order I need the joins to take place is generating an error: "The column prefix 's' does not match with a table name or alias name used in the query." Here are my table joins:
from rmxprod.dbo.candidates c
INNER JOIN rmxprod.dbo.vw_ordercandidates_all oc on oc.candidateid = c.candidateid
INNER JOIN rmxprod.dbo.orders o on o.orderid = oc.orderid
LEFT OUTER JOIN rmxprod.dbo.medicalplans m on m.medicalplandescription = s.reference
LEFT OUTER JOIN rmxprod.dbo.medicalplancosts mc on mc.medicalplanid = m.medicalplanid and mc.clientid = o.clientid
LEFT OUTER JOIN rmxprod.dbo.medicalplancosts mpc on mpc.clientid = -1 and mpc.medicalplanid = m.medicalplanid
LEFT OUTER JOIN integrateprod.dbo.intxref i on i.extid = oc.candidateid and fieldid = 186 and i.subscriberid = 1
LEFT OUTER JOIN #staffserve s on s.intid = i.intid
I need to join medicalplans first, but I cannot figure out how or should I say is it possible to do? I know the reason I am getting the error is because table "s" is not brought into the joins until the end?
Any help provided will be greatly appreciated.
Thanks a bunch!!
-T
from rmxprod.dbo.candidates c
INNER JOIN rmxprod.dbo.vw_ordercandidates_all oc on oc.candidateid = c.candidateid
INNER JOIN rmxprod.dbo.orders o on o.orderid = oc.orderid
LEFT OUTER JOIN rmxprod.dbo.medicalplans m on m.medicalplandescription = s.reference
LEFT OUTER JOIN rmxprod.dbo.medicalplancosts mc on mc.medicalplanid = m.medicalplanid and mc.clientid = o.clientid
LEFT OUTER JOIN rmxprod.dbo.medicalplancosts mpc on mpc.clientid = -1 and mpc.medicalplanid = m.medicalplanid
LEFT OUTER JOIN integrateprod.dbo.intxref i on i.extid = oc.candidateid and fieldid = 186 and i.subscriberid = 1
LEFT OUTER JOIN #staffserve s on s.intid = i.intid
I need to join medicalplans first, but I cannot figure out how or should I say is it possible to do? I know the reason I am getting the error is because table "s" is not brought into the joins until the end?
Any help provided will be greatly appreciated.
Thanks a bunch!!
-T