我有一张桌子: -
+----------+--------------+-------------------+-----------+
| IsActive | IsFirstChunk | TotalResponseTime | StallTime |
+----------+--------------+-------------------+-----------+
| Yes | Yes | 62 | NULL |
| NULL | NULL | 327 | 0 |
| NULL | NULL | 59 | 0 |
我想在列IsActive和IsFirstChunk标记为Yes的行中填充StallTime列的行,其值为TotalResponseTime,因此我的表格如下所示: -
+----------+--------------+-------------------+-----------+
| IsActive | IsFirstChunk | TotalResponseTime | StallTime |
+----------+--------------+-------------------+-----------+
| Yes | Yes | 62 | 62 |
| NULL | NULL | 327 | 0 |
| NULL | NULL | 59 | 0 |
答案 0 :(得分:1)
您可以使用简单的更新语句,将TotalResponseTime
的值分配给StallTime
,其中IsActive
和IsFirstChunk
为yes
update tbl set StallTime=TotalResponseTime where
IsActive='Yes' and IsFirstChunk='yes';
答案 1 :(得分:0)
试试这个,
Update table set StallTime = TotalResponseTime where IsActive = 'Yes'
AND IsFirstChunk = 'Yes'
其他值的替代方法,如null,empty,no,然后尝试
Update table set StallTime = TotalResponseTime where IsActive <> '' AND IsFirstChunk <> ''
试一试,这应该有用。
答案 2 :(得分:0)
您可以通过在where
子句中应用条件来实现此目的。
如果IsActive和IsFirstChunk匹配&#39;是&#39;
update a1
set stallTime = TotalResponseTime
where IsActive in ('yes') and IsFirstChunk in ('yes');
另一种方式
update a1
set stallTime = TotalResponseTime
where IsActive is not null and IsFirstChunk is not null;