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

Can this be done?

Status
Not open for further replies.

enak

Programmer
Jul 2, 2002
412
US
I need to update the values in one table with the values from another table. I have this SQL but I get an error:

UPDATE tblBilling LEFT JOIN tblCaseInfo ON tblBilling.CaseID = tblCaseInfo.CaseID
SET tblBilling.Matter = replicate('0', 7 - len(tblCaseInfo.FileNumber)) + tblCaseInfo.FileNumber,
tblBilling.FileNumber = tblCaseInfo.FileNumber
WHERE tblBilling.FileNumber <> tblCaseInfo.FileNumber

I get the error: "Incorrect syntax near the keyword 'LEFT'."

This SQL will return the values that I want but I don't know how to incorporate it into the update statement:

select tblCaseInfo.FileNumber,replicate('0', 7 - len(tblCaseInfo.FileNumber)) + tblCaseInfo.FileNumber as Matter
from tblbilling left join tblCaseInfo ON tblBilling.CaseID = tblCaseInfo.CaseID
WHERE tblBilling.FileNumber <> tblCaseInfo.FileNumber

Can someone please help me with this?

Thanks
enak
 
It can be done, but your syntax is wrong.

Sorry don't have the time to give example now, but basically you cannot put your 'LEFT JOIN ... ON' command next to the update statement, it must come after the WHERE statement !
 
This should be the proper syntax:

UPDATE tblBilling
SET tblBilling.Matter = replicate('0', 7 -
len(tblCaseInfo.FileNumber)) + tblCaseInfo.FileNumber,
tblBilling.FileNumber = tblCaseInfo.FileNumber
FROM tblBilling
LEFT JOIN tblCaseInfo ON tblBilling.CaseID = tblCaseInfo.CaseID
WHERE tblBilling.FileNumber <> tblCaseInfo.FileNumber

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top