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
精彩评论