简体   繁体   中英

Select Data from multiple databases?

我如何才能同时访问两个不同的数据库,我的意思是可以实现从database1进行搜索并将例如ID或其他信息保存到database2吗?

If you have a user account that can access both databases, just prefix the database name:

SELECT database1.table1, database2.table2.....

as far as I know, you can even do JOINs, although I don't know about possible performance implications.

If you do not have a mySQL account that can access both databases, it's not possible.

Yes. PHP has a few MySQL extensions. However, if you're just getting started, look at the MySQL functions for this. Specifically mysql_connect() and mysql_select_db() could be used to create separate connections to different databases or switch between them on the same connection.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM