create table test(
id integer primary key,
name varchar(100)
);
例如現在在test表中有N條數據,其中有兩條爲
12, 'hello'
13, 'world'
如果想把上一條中的數據改成和下一條記錄一樣(id除外),那麼當數據比較少時,可以直接使用
update test set name='world' where id=12;
但如果這個表中的數據比較多時,這麼做就有些麻煩了,可以利用join的方式:
update test a join test b on a.id=12 and b.id=13 set a.name = b.name;
注意:是join,而不是left join或 right join