Heim  >  Artikel  >  Backend-Entwicklung  >  PHP 怎么写多个数据库之间查询的语句

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

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

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


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

select * from database1.table1, database2.table2 where ...
------解决方案--------------------
如果你两个数据库可以用同一个帐号密码访问,则可以用
database1.table1
database2.table2
这个形式
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:请问个正则表达式的有关问题,Nächster Artikel:php除开html标签