UPDATE rows with values from the same table
问题 I have a table like this: +------+-------+ |ID | value | +------+-------+ | 1 | 150 | | 2 | | | 3 | | | 4 | | | 5 | 530 | | 6 | 950 | | 7 | 651 | +-------+------+ I want to copy the last 3 values and at the end my table will look like this: +------+-------+ |ID | value | +------+-------+ | 1 | 150 | | 2 | 530 | | 3 | 950 | | 4 | 651 | | 5 | 530 | | 6 | 950 | | 7 | 651 | +-------+------+ Is it possible? 回答1: Use a self-join : UPDATE mytable m SET value = m0.value FROM mytable m0 WHERE m.id =