Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mysql Query - Different Servers

Status
Not open for further replies.

johnnyasterisk

IS-IT--Management
Apr 2, 2008
26
IE
I have 2 servers:

1.1.1.1 and 1.1.1.2 both running mysql

1.1.1.1 has a table called table1
1.1.1.2 has a table called table2

Both of these tables are the exact same structure. I need to know how to do the following:

on table2 select the max(id) then use that value to:

insert into table2 the records that have an id of > max(id) of table2

I need this to run every 15 mins so dont want to have to worry about exporting to a file and importing.

This is basically a replication script that will copy any uncopied data from server1.table1 to server2.table2

Thanks in advance for any input.

The JA
 
You can use the "federated" engine to access the table from the other server, or do the whole thing from a CRON job that connects to both servers.

+++ Despite being wrong in every important aspect, that is a very good analogy +++
Hex (in Darwin's Watch)
 
Or you could have two connections in the PHP (or whatever !) to the different servers and do whast needs to be done.
 
guys thanks for your replies. I have created a php script that does what I required above and I run that every 15 mins in a cron job.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top