跨不同数据库选择列

2021-11-20 00:00:00 mysql

是否可以跨位于同一服务器上的不同数据库执行选择(或插入)语句?如果是,如何?

Is it possible to do a select ( or insert) statement across different databases that are located on the same server? If yes, how?

推荐答案

您可以使用语法 databasename.tablename

示例:

SELECT 
    mydatabase1.tblUsers.UserID, 
    mydatabse2.tblUsers.UserID
FROM 
   mydatabase1.tblUsers
       INNER JOIN mydatabase2.tblUsers 
           ON mydatabase1.tblUsers.UserID = mydatabase2.tblUsers.UserID

相关文章