1.两张表之间无联系:
select A.ID,A.UserName from DB1.dbo.Table1 A where A.Account='admin' union select B.ID,B.UserName from DB2.dbo.Table2 B where B.Account='admin'
2.两张表之间有联系:
select * from DB1.dbo.Table1 A , DB2.dbo.Table2 B where A.Account = B.ID -------- or ------- select * from DB1.dbo.Table1 A inner join DB2.dbo.Table2 B on A.account = B.ID
备注:可以只创建一个数据库连接!