0

在我的情况下,我想运行更新查询以在指定日期期间更新 PercentAvailability 列值 0 到 100 2012-10-28 03:31:01 to 2012-10-28 08:31:01。见下图。

在此处输入图像描述

如何运行查询以在指定日期之间更新上述数据?

注意:我有很多 ApplicationID 都有这个问题,所以我如何对所有 ApplicationID 运行查询,我相信我们需要运行 JOIN 语法,但如果你给出一些简短的提示会很好。

4

1 回答 1

5

使用此查询

update your_table
set PercentAvailability = 100
where PercentAvailability = 0
and [DateTime] between '2012-10-28 03:31:01' and '2012-10-28 08:31:01'

或者,如果您只想为特定更新相同的内容,ApplicationID请执行

update your_table
set PercentAvailability = 100
where PercentAvailability = 0
and [DateTime] between '2012-10-28 03:31:01' and '2012-10-28 08:31:01'
and ApplicationID = 1235

ApplicationID多做

update your_table
set PercentAvailability = 100
where PercentAvailability = 0
and [DateTime] between '2012-10-28 03:31:01' and '2012-10-28 08:31:01'
and ApplicationID in (1235, 1236, 1237)

或者对于一个大数字或者ApplicationID你可以做一个子查询

update your_table
set PercentAvailability = 100
where PercentAvailability = 0
and [DateTime] between '2012-10-28 03:31:01' and '2012-10-28 08:31:01'
and ApplicationID in (select ApplicationID from another_table where somecondition)
于 2012-10-31T18:55:24.367 回答