Unix Technical Forum

How to compare rows in different tables?

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


Go Back   Unix Technical Forum > Database Server Software > MySQL > MySQL General forum

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-14-2008, 05:46 PM
mos
 
Posts: n/a
Default How to compare rows in different tables?

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-14-2008, 05:46 PM
Rob Wultsch
 
Posts: n/a
Default Re: How to compare rows in different tables?

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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-14-2008, 05:46 PM
mos
 
Posts: n/a
Default Re: How to compare rows in different tables?

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:23 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com