I'm attempting to update a table using a join statement, but it isn't exactly working out. I need to be able to update a certain row in the database when one condition is true, using data from a different table. Here is what I have so far, maybe I am close and someone could provide some insight?
UPDATE Project
SET Project.SumAssessments = SUM (Assessment.Amount)
FROM Project
JOIN Assessment ON Project.SumAssessments = SUM (Assessment.Amount)
WHERE Assessment.ProjectCode = @ProjectID
AND Project.ProjectID = @ProjectID
SET
is updating a value that based on theJOIN
would already equal that value. I could easily fix your syntax to make it work, but the code would have no effect. We need to know what you're actually trying to update and on what condition, it currently makes little sense.