Link to home
Start Free TrialLog in
Avatar of Fordraiders
FordraidersFlag for United States of America

asked on

Inner Joining 3 tables from 3 different databases

Does anyone have sample sql statement, using  -- Inner Joining  3 tables from 3 different databases  ?
Please

Very hard to find these types of examples...

Thanks
fordraiders
Avatar of chapmandew
chapmandew
Flag of United States of America image

select d1.field, d2.field, d3.field
from
database1.dbo.tablename d1
join database2.dbo.tablename d2 on d1.field2 = d2.field2
join database3.dbo.tablename d3 on d2.field3 = d3.field3

make sense?
ASKER CERTIFIED SOLUTION
Avatar of hyphenpipe
hyphenpipe
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Fordraiders

ASKER

Yes, They are in the same "instance".

Here is what works for 2 tables from 2 different databases..

select SKU_VIEW.ITEM,
       SKU_VIEW.WWGMFRNAME,
       SKU_VIEW.WWGMFRNUM,
       WWGDESC_ALL.dbo.WwgDescRich.RICHTEXT
      from ITEM_DISPLAY.dbo.SKU_VIEW INNER JOIN WWGDESC_ALL.dbo.WwgDescRich ON
ITEM_DISPLAY.dbo.SKU_VIEW.ITEM = WWGDESC_ALL.dbo.WwgDescRich.ITEM


I would like to do the same with another table from another databases.

Database =   XrefInfo
Table name =  dbo.XrefDetail
pk column =     ITEM
Field I need in the query =  REDBOOKNUM

Sorry ,  Guess I should have added this to the question..

Thanks
fordraiders

 




SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks to all !