Page 1 of 1

Consult between 2 server

Posted: Fri 07 May 2010 13:55
by cybsistemas
This can be done ?

UPDATE [email protected] SET fieldname1 = (SELECT fieldname2 FROM [email protected] WHERE tablename2.id = tablename1.id);

As it would be the sentence

Posted: Tue 11 May 2010 08:13
by Dimon
MySQL server doesn't allow such syntax.

Posted: Tue 11 May 2010 10:26
by cybsistemas
Thanks

Posted: Sun 23 May 2010 23:46
by cybsistemas
Yes, It can with engine Federated. (1,7 seconds)

But is faster that way:

MyConnectionLocal.Server: = 'localhost';
MyConnectionRemote.Server: = 'remote.dyndns.org;

MyCommandLocal.SQL.Text: = 'insert into tableLocal select Id, price from articles;
MyCommandLocal.SQL.Add ('where mark = true ');
MyCommandLocal.Execute; / / (5 records)

DumpLocal.Tablenames: = 'TableLocal;
DumpLocal.BackupToFile ('File.Sql');


DumpRemote.RestoreFromFile ('file.sql');

MyCommandRemote.Sql.Text: = update articles set price = select price from tableremote where articles.id = tableremote.id'
MyCommandRemote.Execute; / / (0,7 seconds)