使用连接更新查询

时间:2012-05-21 10:01:28

标签: asp.net gridview

UPDATE project_phases p2 
SET 
  p2.ClartiyID = @ClarityID,
  p2.Start_date = @start_date,
  p2.End_date = @End_date,
  p2.Planned_efforts = @Planned_efforts 
FROM 
  WSR.dbo.project_phases p2 
  INNER JOIN WSR.dbo.tb_Project p1 ON p1.ProjectID=p2.ProjectID 
WHERE 
  ProjectID = @ProjectID

但是仍然找不到像对象名称那样的错误,即使该表找到了

1 个答案:

答案 0 :(得分:1)

如果这是您的整个查询,为什么要链接到tb_Project?看起来这只是为了过滤ProjectID,但是这个列在Project_Phases中,所以你不能忘记INNER JOIN并只使用:

UPDATE project_phases 
SET 
  ClartiyID = @ClarityID,
  Start_date = @start_date,
  End_date = @End_date,
  Planned_efforts = @Planned_efforts 
WHERE 
  ProjectID = @ProjectID