现在有
product表
列名:category:是原来老的产品分类ID号
classinfo表
列名:classid:新ID号
oldclassid:老的ID号
对应product.category的号现在想把product里的每条记录的category更新为classinfo里的classinfo条件是,product.category号等于product.oldclassid号

解决方案 »

  1.   

    update product  set category=(select top 1 classid from classinfo where product.category=classinfo.oldclassid)这样行不行
      

  2.   

    试一下
    update product
    set a.category = b.classid
    from product a,
    classinfo b
    where a.category = b.oldclassid
      

  3.   

    update product
    set category = classinfo.classid
    from product,classinfo
    where product.category = classinfo.oldclassid
      

  4.   

    在表中oldclassid唯一不?
    如果唯一则可以用如下语句,如果不唯一则可能需要加其他的条件来选择更新啦.
    update product set category=(select classid from classinfo where product.category=classinfo.oldclassid)
      

  5.   

    ayouaja(向龙虾学习) ( ) 信誉
    试一下
    update product
    set a.category = b.classid
    from product a,
    classinfo b
    where a.category = b.oldclassid
    -------------------------------
    无法使用列前缀 'a'。此前缀必须与 UPDATE 子句 'product' 中的对象匹配
      

  6.   

    dawugui(潇洒老乌龟)
    的办法可以
    vfp_system(菜鸟一个)
    那个,其实和我二楼和方法一样,全部变成了null谢谢各位,我结了
      

  7.   

    update product 
    set category = b.classid
    from product a, classinfo b 
    where a.categroy=b.oldclassid