开发者

My update query executes but doesn't update

开发者 https://www.devze.com 2023-01-01 01:03 出处:网络
I have this update query. UPDATE production_shr_01 SETtotal_hours = hours, total_weight = weight, percentage = total_hours / 7893.3

I have this update query.

UPDATE production_shr_01
SET    total_hours = hours, total_weight = weight, percentage = total_hours / 7893.3
WHERE  (status = 'X')

The query executes fine but the problem is that wh开发者_Python百科en this query executes, it doesn't update the percentage field. What might be the problem?


Either status = 'X' doesn't find any rows or (and the next is more likely) since you update total_hours in the same statement, total_hours could be 0 (or NULL) and therefor no update; I'd suggest you use the hours field for updating like this:

UPDATE production_shr_01
SET    total_hours = hours, total_weight = weight, percentage = hours / 7893.3
WHERE  (status = 'X')


In percentage = total_hours / 7893.3 clause, the old value of total_hours will be used. Percentage was updated but with the old value. So it looks like it was not updated. Please use percentage = hours/ 7893.3

0

精彩评论

暂无评论...
验证码 换一张
取 消