How to compare rows in different tables?

How to compare rows in different tables?

am 13.07.2008 00:07:31 von mos

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=gcdmg-mysql-2@m.gmane.org

Re: How to compare rows in different tables?

am 13.07.2008 02:05:28 von Rob Wultsch

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 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)

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org

Re: How to compare rows in different tables?

am 13.07.2008 05:31:44 von mos

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 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


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org