php - How can connect to two databases in same time and query data in mysql, I have same host -
i have 2 database, & b how can copy data b using mysql, did there wrong, there 2 same tables called members in & b, , want copy username a.members b.members. there error ! can using mysql, can me solve problem because must connect databases & b in same time query data
mysql_connect("$host", "$user", "$pass"); mysql_select_db("a"); mysql_connect("$host", "$user2", "$pass2"); mysql_select_db("b"); //host = host b same host $mysql="select username a.members insert b.members"; $result= mysql_query($mysql);
if connecting same host, need make connection once. , setting default database using mysql_select_db("a");
should not necessary because specifying database use in statement.
the sql insert should be:
insert b.members (username) select username a.members
check out the documentation insert...select.
Comments
Post a Comment