Problem with Join in SQL with 2 databases
I am not so good at sql server. I am trying to do something like this
Select * from Page_Image_ID, PageID, DI_ImageID, caption, sort_order
from Merchant_Sub开发者_JAVA技巧pages_images
where PageID = 12345
This gets me right values. My problem here is that for every DI_ImageID, there is a row in a an other table from other database which i want along with the above result.
For each DI_ImageID, Select * from DI_Image from Images where DI_ImageID = @(all above IDs)
How is it possible, guys? Thanks a lot in advance!!
You can INNER JOIN on the common field;
Select
S.Page_Image_ID,
S.PageID,
S.DI_ImageID,
S.caption,
S.sort_order,
I.*
from Merchant_Subpages_images S
inner join otherdbname.dbo.Images I ON S.DI_ImageID = I.DI_ImageID
where S.PageID = 12345
精彩评论