在1个SQL语句中组合更新查询

时间:2013-03-22 23:34:49

标签: sql union updates

我正在尝试将两个更新查询合并到一个sql语句中。我以为我可以使用联合查询来组合查询,但我无法。有什么建议?我想要组合的查询如下:

UPDATE PromotionDatabase
  SET PromotionDatabase.PromotionWeekEndingSunday = [PromotionDatabase]![Start Date]+-(Weekday([PromotionDatabase]![Start Date])-1)+7 

UPDATE PromotionDatabase
  SET PromotionDatabase.PromotionEndingWeekEndingSunday = [PromotionDatabase]![End Date]+-(Weekday([PromotionDatabase]![End Date])-1)+7;

2 个答案:

答案 0 :(得分:0)

您是否只是尝试更新同一UPDATE语句中的两个字段:

UPDATE PromotionDatabase
SET PromotionWeekEndingSunday = [Start Date]+-(Weekday([Start Date])-1)+7,
   PromotionEndingWeekEndingSunday = [End Date]+-(Weekday([End Date])-1)+7;

答案 1 :(得分:0)

更新的语法如下。见w3schools

UPDATE table_name
SET column1=value, column2=value2,...
WHERE some_column=some_value