php - Select Data from multiple databases?


How can i access in two different databases at the same time, i mean can i implement a search from database1 and save for example the id or another information to a 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. Specificallymysql_connect() andmysql_select_db() could be used to create separate connections to different databases or switch between them on the same connection.

People are also looking for solutions to the problem: apache - PHP file include - permission denied on Windows 7


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.