0
我想從main_table中獲取持續時間列中的值,從列中的每個值中獲取子結構1(一),然後使用差異更新同一列(子結構之後的結果)例如更新同一個表的數據列後減去數值
main_table (before any operation)
--------------------------------
id duration
1 x
2 y
3 z
main_table (after update operation)
--------------------------------
id duration
1 x - 1
2 y - 1
3 z - 1
這裏是我迄今爲止嘗試和失敗
UPDATE main_table mt, (SELECT duration - 1 AS remaining
FROM main_table mt1
) mt1
SET mt.duration = mt1.remaining
WHERE mt.id = mt1.id
建議你們實現這個!