How does PHP write statements for queries between multiple databases?

Source: Internet
Author: User
Tags php write
How does PHP write statements for queries between multiple databases? Two data tables, table1table2table1 & nbsp; table2 & nbsp in database1; in database2, how can I query data in table2 through table1? ------ Solution ------------------ in the table PHP, how do I write statements for queries between multiple databases?
Two data tables
Table1
Table 2
Table1 in database1
Table2 in database2
How can I query data in table 2 through table1 data?


------ Solution --------------------
Add the database name before the table name, with the condition that the current user has access to both databases.

Select * from database1.table1, database2.table2 where...
------ Solution --------------------
If the two databases can be accessed using the same account password, you can use
Database1.table1
Database2.table2
This form

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.