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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

REPLACE quirie

Status
Not open for further replies.

yigalm

Technical User
Aug 16, 2001
42
US
Hi,

I cannot get a replace querie to replace data in one table with fields from another. Instead, it appends new rows.
In both tables I made one field a UNIQUE KEY. This field is the common denominator in the two tables. But when I say:
replace tbl1 (fld1, fld2)
select fld1, fld2
from tbl2;

when tbl1.fld3 and tbl2.fld3 are UNIQUE KEYs and they are supposed to be the same in both tables (tbl1 has more entries than tbl2), the querie appends new rows.

What am I doing wrong, that the REPLACE appends instead of updating?

Thank you
 
Hiya,

You need to use the update query to do this:

UPDATE tbl1
SET fld1 = tbl2.fld1,
fld2 = tbl2.fld2
FROM tbl2;

HTH

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top