记录的一个字段赋值给还有一个字段
update tb set Lastdate= regdate where XXX
5.将一个表中的一批记录更新到另外一个表中
table1
ID f1 f2
table2
ID f1 f2
先要将table2中的f1 f2 更新到table1(同样的ID)
update table1,table2 set table1.f1=table2.f1,table1.f2=table2.f2 where =
6.将同一个表中的一些记录更新到另外一些记录中
表:a
ID month E_ID Price
1 1 1 2
2 1 2 4
3 2 1 5
4 2 2 5
先要将表中2月份的产品price更新到1月份中
显然,要找到2月份中和1月份中ID同样的E_ID并更新price到1月份中
这个全然能够和上面的方法来处理,只是因为同一表,为了区分两个月份的,应该将表重命名一下
update a,a as b set = where a.E_ID=b.E_ID and =1 and =2
当然,这里也能够先将2月份的查询出来,在用5.的方法去更新
update a,(select * from a where month=2)as b set = where a.E_ID=b.E_ID and =1