在表之间使用INNER JOIN更新查询?

时间:2014-11-19 10:53:49

标签: c# sql asp.net

我正在尝试在执行内部联接后更新一个数据库中的表中的列。使用下面给出的查询时显示错误。错误是:"Unable to parse query text."帮我找到合适的解决方案。谢谢。

SQL:

UPDATE  tbl_plan SET Mail_Status = 'Sent' INNER JOIN
tbl_Assignment ON tbl_Assignment.Plan_ID = tbl_plan.Plan_ID
WHERE (DATEDIFF(dd, { fn NOW() }, Date) = 2) AND (Mail_Status IS NULL)

1 个答案:

答案 0 :(得分:3)

您有一个更新查询的格式,其中的连接稍有错误。试试这个

UPDATE p  
SET Mail_Status = 'Sent' 
FROM tbl_plan p
INNER JOIN tbl_Assignment a ON a.Plan_ID = p.Plan_ID
WHERE (DATEDIFF(dd, { fn NOW() }, Date) = 2) AND (Mail_Status IS NULL)