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

Doing an UPDATE 1

Status
Not open for further replies.

LeonelSanchezJr

Programmer
Jan 26, 2001
522
US
I wrote the following query to pull up some records from some tables which have incorrect data.

The Hlpdsk_All Table (contains all fields for the two tables: HelpDesk and CallNotes) and has the correct values (text) for the field cCAllNotes.

However, the CallNotes table must have its values REPLACED with the correct values from the Hlpdsk_All.cCallNotes field.

**********************************************************
Select Hlpdsk_All.cProblemNum, Hlpdsk_All.cCallNotes,
Callnotes.cCallNotes
from hlpdsk_all
left join helpdesk on hlpdsk_all.cproblemnum =
helpdesk.cproblemnum
left join callnotes on helpdesk.icallnoteskey =
callnotes.id
where hlpdsk_all.drecorded >= '05/23/01' and
hlpdsk_all.drecorded < '05/24/01'


I need to write the code to REPLACE CallNotes.cCallnotes with the value from HlpDSk_all.cCallnotes. The problem is that the CALLNOTES table only has two fields: ID and cCallNotes. The HelpDesk table references the CALLNOTES table based on HelpDesk.iCallNotesKey.
 

Try the following.

UPDATE Callnotes SET cCallNotes = c.cCallNotes
FROM Callnote a
INNER JOIN HelpDesk b
ON a.ID=b.icallnoteskey
INNER JOIN Hlpdsk_All c
ON b.cproblemnum=c.cproblemnum

Terry
------------------------------------
Blessed is the man who, having nothing to say, abstains from giving us worthy evidence of the fact. -George Eliot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top