我有3个具有相同表格的数据库。现在我想结合来自不同数据库的3个表,并在每个表上进行连接以获取其他信息。不幸的是,这不起作用,因为语法不正确。这可能吗?
像这样:SELECT *
FROM (
SELECT ID, [Address], Matchcode, [Name], Country, Place, ZIP, Street FROM [Czech].[dbo].[Addresses] a
LEFT JOIN [Czech].[dbo].[Account] k ON (a.ID = k.ID AND a.Address = k.Address)
UNION
SELECT ID, [Address], Matchcode, [Name], Country, Place, ZIP, Street FROM [Germany].[dbo].[Addresses] a
LEFT JOIN [Germany].[dbo].[Account] k ON (a.ID = k.ID AND a.Address = k.Address)
UNION
SELECT ID, [Address], Matchcode, [Name], Country, Place, ZIP, Street FROM [Austria].[dbo].[Addresses] a
LEFT JOIN [Austria].[dbo].[Account] k ON (a.ID = k.ID AND a.Address = k.Address)
) AS AddressAll WHERE [Address] = '1010'
在我的帐户表格中,我为每个地址设置了一些特定的列,例如sales,amount,taxID,lastSale,.... 不幸的是,我们有3个不同国家的公司,这就是为什么有3个表格。
目标是在这多个表上使用WHERE子句。