View Full Version : How do I compare these 2 tables ?

01-11-2010, 07:11 PM

I have two comparisons that I need to do and they are a bit
beyond my knowledge, would appreciate some help. :)

I have two tables that have an identical structure,
one is the incoming daily update, tableA which I want to
compare to the history tableB.

Both structures look like this:
id, title, desc, data1, data2, ... data18

The first comparison is to check for new rows. I think I can
do this by using the LEFT JOIN command

Is this how I do it ?

$query = "SELECT tableA.*, tableB.* FROM tableA LEFT JOIN tableB ON tableA.id = tableB.id";

$result = mysql_query($query) or die(mysql_error());

My second comparison is to compare all the rows that have same ids
but have differences in the other fields i.e. not NEW records but CHANGED records.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum