Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
December 1, 2005, 8:23 am
rate this thread
I have 2 or more PCs installed with mysql database, with same or almost
same table structure, but with different data. Can I combine those
data into one database?
suppose: one pc server has main database with main data, another pc has
some special data, I need combine those data into the main database, if
main database already have the data, then dont' change it, if main
database doesn't have the data, then append it into main database.
Is there an easy way to implement it?
Re: About combining data in different mysql database
Yes, you can use `databasename`.`tablename` in SQL statements, so you
should be able to do this:
INSERT IGNORE INTO maindatabase.table1 (column1, column1, column3)
SELECT column1, column2, column3
The "IGNORE" keyword means that if the operation gets a duplicate key
error as it attempts to insert a row, do not abort (but that row is
still not inserted). So the records that succeed will be only those
that have distinct values for the primary key.
Though this doesn't detect cases where you have rows that are the "same"
data but have distinct primary key values in the special database versus
the main database. That's harder to detect automatically.
- » Americanas.com SALDO de TVs Com at 80% de Desconto (29798)
- — Newest thread in » MySQL Database Forum