现在有
product表
列名:category:是原来老的产品分类ID号
classinfo表
列名:classid:新ID号
oldclassid:老的ID号
对应product.category的号现在想把product里的每条记录的category更新为classinfo里的classinfo条件是,product.category号等于product.oldclassid号
product表
列名:category:是原来老的产品分类ID号
classinfo表
列名:classid:新ID号
oldclassid:老的ID号
对应product.category的号现在想把product里的每条记录的category更新为classinfo里的classinfo条件是,product.category号等于product.oldclassid号
update product
set a.category = b.classid
from product a,
classinfo b
where a.category = b.oldclassid
set category = classinfo.classid
from product,classinfo
where product.category = classinfo.oldclassid
如果唯一则可以用如下语句,如果不唯一则可能需要加其他的条件来选择更新啦.
update product set category=(select classid from classinfo where product.category=classinfo.oldclassid)
试一下
update product
set a.category = b.classid
from product a,
classinfo b
where a.category = b.oldclassid
-------------------------------
无法使用列前缀 'a'。此前缀必须与 UPDATE 子句 'product' 中的对象匹配
的办法可以
vfp_system(菜鸟一个)
那个,其实和我二楼和方法一样,全部变成了null谢谢各位,我结了
set category = b.classid
from product a, classinfo b
where a.categroy=b.oldclassid