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

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

WBOY
Release: 2016-06-13 12:57:20
Original
1432 people have browsed it

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


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

select * from database1.table1, database2.table2 where ...
------解决方案--------------------
如果你两个数据库可以用同一个帐号密码访问,则可以用
database1.table1
database2.table2
这个形式
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template