How do I connect to two databases at the same time
Can you help!! I have two databases on one MySql sever and I would like to transfer certain information from one databases to another. I want to transfer, record by record, from a particular table, after examining the record. How can I open the two databases at the same time? The only way I am able to do this is by 1. opening one database - 2. read a record from a particular table - 3. close the database - 4. examine the records - 5. open the other database - 6. save information and close. 7. repeat the process for all the records. I am worried that this may be in efficient. It there another I could do it? Fred Kamwaza - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: How do I connect to two databases at the same time
Fred, Monday, June 10, 2002, 2:22:25 PM, you wrote: FK I have two databases on one MySql sever and I would like to transfer FK certain information from one databases to another. I want to transfer, FK record by record, from a particular table, after examining the record. How FK can I open the two databases at the same time? FK The only way I am able to do this is by FK 1. opening one database - FK 2. read a record from a particular table - FK 3. close the database - FK 4. examine the records - FK 5. open the other database - FK 6. save information and close. FK 7. repeat the process for all the records. FK I am worried that this may be in efficient. It there another I could do it? You can specify database name in SQL statement, f.e. INSERT database1.table1 SELECT * FROM database2.table2 WHERE ... ; It will work if your databases are located on the same MySQL server (in one MySQL data dir). FK Fred Kamwaza -- For technical support contracts, goto https://order.mysql.com/?ref=ensita This email is sponsored by Ensita.net http://www.ensita.net/ __ ___ ___ __ / |/ /_ __/ __/ __ \/ /Victoria Reznichenko / /|_/ / // /\ \/ /_/ / /__ [EMAIL PROTECTED] /_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.net ___/ www.mysql.com - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
RE: How do I connect to two databases at the same time
Thanks for your reply. I am actually using PHP and I tried what you suggested. $link1 = mysql_connect(server1.com, www, pass) or die(could ...); $link2 = mysql_connect(server1.com, www, pass) or die(could ...); there is no error but it is not working. Please not that I am using the same server. Fred Kamwaza. I don´t know what API or languaje are you usin, but i think in c, perl, php you should open two conection with two diferent names $link=mysql_connect(192.168.1.11, www, pass) or die (Could not connect); $link2=mysql_connect(192.168.1.10, www, pass) or die (Could not connect); and work with the pointers all time I think it should work -Mensaje original- De: Fred Kamwaza [mailto:[EMAIL PROTECTED]] Enviado el: lunes, 10 de junio de 2002 13:22 Para: [EMAIL PROTECTED] Asunto: How do I connect to two databases at the same time Can you help!! I have two databases on one MySql sever and I would like to transfer certain information from one databases to another. I want to transfer, record by record, from a particular table, after examining the record. How can I open the two databases at the same time? The only way I am able to do this is by 1. opening one database - 2. read a record from a particular table - 3. close the database - 4. examine the records - 5. open the other database - 6. save information and close. 7. repeat the process for all the records. I am worried that this may be in efficient. It there another I could do it? Fred Kamwaza - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
RE: How do I connect to two databases at the same time
Both of the connections shown below are for the same database server. If both dbs are on the same server you only need one connection, but then you need to use mysql_select_db($database_name,$link1) for each database. Andrew Hazen -Original Message- From: Fred Kamwaza [mailto:[EMAIL PROTECTED]] Sent: Monday, June 10, 2002 10:21 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: How do I connect to two databases at the same time Thanks for your reply. I am actually using PHP and I tried what you suggested. $link1 = mysql_connect(server1.com, www, pass) or die(could ...); $link2 = mysql_connect(server1.com, www, pass) or die(could ...); there is no error but it is not working. Please not that I am using the same server. Fred Kamwaza. I don´t know what API or languaje are you usin, but i think in c, perl, php you should open two conection with two diferent names $link=mysql_connect(192.168.1.11, www, pass) or die (Could not connect); $link2=mysql_connect(192.168.1.10, www, pass) or die (Could not connect); and work with the pointers all time I think it should work -Mensaje original- De: Fred Kamwaza [mailto:[EMAIL PROTECTED]] Enviado el: lunes, 10 de junio de 2002 13:22 Para: [EMAIL PROTECTED] Asunto: How do I connect to two databases at the same time Can you help!! I have two databases on one MySql sever and I would like to transfer certain information from one databases to another. I want to transfer, record by record, from a particular table, after examining the record. How can I open the two databases at the same time? The only way I am able to do this is by 1. opening one database - 2. read a record from a particular table - 3. close the database - 4. examine the records - 5. open the other database - 6. save information and close. 7. repeat the process for all the records. I am worried that this may be in efficient. It there another I could do it? Fred Kamwaza - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php