Home  >  Article  >  Backend Development  >  PHP 怎么写多个数据库之间查询的语句

PHP 怎么写多个数据库之间查询的语句

WBOY
WBOYOriginal
2016-06-13 11:10:23704browse

PHP 如何写多个数据库之间查询的语句?
两个数据表
table1
table2
table1 在database1中
table2 在database2中
如何通过table1的数据来查询table2中中的数据?


------解决方案--------------------
在表名前加上库名即可,条件是当前用户对两个库都有访问权限

select * from database1.table1, database2.table2 where ...
------解决方案--------------------
如果你两个数据库可以用同一个帐号密码访问,则可以用
database1.table1
database2.table2
这个形式
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn