sql 中修改一列的数据

有一个表emlpoyee 里面有 id 和cost 和 order
数据里已经有了 id 1 cost 1000 order 2
id 2 cost 2000 order 3
只需要把 id 2中的2000 加到 id1中的 1000 结果 id1的cost为3000
这句话 怎么写啊

对你的意思不够明白,不过就你字面意思的话,如下就可以实现了:
update emlpoyee set cost=
(select sum(cost) from emlpoyee where (id=1 or id=2))
where id=1
温馨提示:答案为网友推荐,仅供参考
第1个回答  2009-04-14
update emlpoyee set cost=(select cost from emlpoyee where id=1)+(select cost from emlpoyee where id=2) where id=1
第2个回答  2009-04-14
update emlpoyee set cost=
(select sum(cost) from emlpoyee where id=1 and id=2) where id=1
第3个回答  2009-04-14
没明白什么意思
id1 cost1000是什么意思
相似回答