Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to update rows in one table depending on another table

Status
Not open for further replies.

aas1611

Programmer
Dec 14, 2001
184
DE
Hi!

Maybe my subject is a little confusing. So I hope the following can make it clearer:

I have two tables, T1 and T2. These two have (almost) identical fields. In fact, we can assume that T2 is a copy of T1. The unique field for both is ID. Each table has 11K rows. The difference is, T1 is a table in mysql, and T2 is a table in Access. I made a link to T1 from Access.

The problem:
if someone makes changes on T1 (from internet) for some particular row(s), these changes have to be updated also in T2 (from Access).

How can I make a good query in Access for this purpose?

Thanks for any hint!

Andre
 
The general approach is
Code:
UPDATE T1 INNER JOIN T2
       ON T1.ID = T2.ID

SET    T1.Fld1 = T2.Fld1

WHERE T1.Fld1 <> T2.Fld1 
   OR T2.Fld1 IS NULL 
   OR T1.Fld1 IS NULL
on an individual field basis. You need the IS NULL bits because comparison operators (like <>) don't work correctly on NULLs.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top