Execute two databases at a time

Source: Internet
Author: User
At the same time execute two server inside two database, this execution statement how to write? Thank you!


Reply to discussion (solution)

Just give the strap a prefix.

The first step: connect to the database, but do not connect to the specific database;
Step two: Precede the table name with a specific database name and use "." Connection.

Why do I have to execute both servers ' databases at the same time? Keep your data unified?
Assuming this is the case, the execution of a database on a server is OK, the other one to do from the database, master and slave hot standby.
Hypothesis only.

Two connections, call two times. No other special.

Yes, what I want to know is why it's so designed ....

1 2lou No. This construct cannot be executed at the same time. It is possible to have two libraries of the same server.

Executes two times mysql_connect, saving the handle separately.
From one database Select, parse the data, and then update to another.

At the same time, switching the database can be done.

Oh, at the same time connecting two databases is actually the same
$con = Mysql_connet ("host_name", "username", "table_name");
$db 1 = mysql_select_db ("Database 1", $con);
$db 2 = mysql_select_db ("Database 2", $con);


$sql = "SELECT * FROM table"
$row 1 = mysql_query ($sql, $db 1);

$sql 2 = "SELECT * FROM Table2"
$row 2 = mysql_query ($sql, $db 2);

It can also be packaged into classes for convenience.

  • 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.