This is a discussion on How to compare rows in different tables? within the MySQL General forum forums, part of the MySQL category; --> I have 2 tables (TblNew: Memory Table, TblOld: MyISAM table) with identical structure and each has approx 75 columns ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I have 2 tables (TblNew: Memory Table, TblOld: MyISAM table) with identical structure and each has approx 75 columns in it. I need to update TblOld with rows in TblNew if any of the values are different, or insert the TblNew rows into TblOld if they are are missing. The two tables have the same keys, Product_Id, Product_Date. I've been using Replace but that will replace all the matching rows in TblOld with TblNew even if the rows are identical. I was hoping there was some sort of row CheckSum so I could compare the checksum of TblOld rows to the checksum in TblNew rows and if they are different, do a Replace on those rows. If the checksums are the same I'd skip them, and if TblNew doesn't have the rows, I'd insert them. Does this make sense? Is this possible or is there a better way to sync a table in the same database? Only TblOld needs to be updated. Mike MySQL 5 |
| |||
| I suggest taking a look at mk-table-sync available from http://www.maatkit.org/ . On Sat, Jul 12, 2008 at 3:07 PM, mos <mos99@fastmail.fm> wrote: > I have 2 tables (TblNew: Memory Table, TblOld: MyISAM table) with identical > structure and each has approx 75 columns in it. I need to update TblOld with > rows in TblNew if any of the values are different, or insert the TblNew rows > into TblOld if they are are missing. The two tables have the same keys, > Product_Id, Product_Date. I've been using Replace but that will replace all > the matching rows in TblOld with TblNew even if the rows are identical. I > was hoping there was some sort of row CheckSum so I could compare the > checksum of TblOld rows to the checksum in TblNew rows and if they are > different, do a Replace on those rows. If the checksums are the same I'd > skip them, and if TblNew doesn't have the rows, I'd insert them. > > Does this make sense? Is this possible or is there a better way to sync a > table in the same database? Only TblOld needs to be updated. > > Mike > > MySQL 5 > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: http://lists.mysql.com/mysql?unsub=wultsch@gmail.com > > -- Rob Wultsch wultsch@gmail.com wultsch (aim) |
| ||||
| At 07:05 PM 7/12/2008, Rob Wultsch wrote: >I suggest taking a look at mk-table-sync available from >http://www.maatkit.org/ . > >On Sat, Jul 12, 2008 at 3:07 PM, mos <mos99@fastmail.fm> wrote: > > I have 2 tables (TblNew: Memory Table, TblOld: MyISAM table) with identical > > structure and each has approx 75 columns in it. I need to update TblOld > with > > rows in TblNew if any of the values are different, or insert the TblNew > rows > > into TblOld if they are are missing. The two tables have the same keys, > > Product_Id, Product_Date. I've been using Replace but that will replace all > > the matching rows in TblOld with TblNew even if the rows are identical. I > > was hoping there was some sort of row CheckSum so I could compare the > > checksum of TblOld rows to the checksum in TblNew rows and if they are > > different, do a Replace on those rows. If the checksums are the same I'd > > skip them, and if TblNew doesn't have the rows, I'd insert them. > > > > Does this make sense? Is this possible or is there a better way to sync a > > table in the same database? Only TblOld needs to be updated. > > > > Mike > > > > MySQL 5 Rob, Thanks for the link. Mike |
| Thread Tools | |
| Display Modes | |
|
|