产品分类表 productclass
classid classname class_time用户产品分类表user_roductclass
id classid classname userid (其中classid与productclass表中的classid外键)现在用户产品分类表中id,classid,userid有数据,而classname没有数据,我想用sql语句从产品分类表中的classname值放到roductclass表的classname中
我的写法是:
update from user_productclass u set classname=(select classname from productclass pr where pr.classid=u.classid) where userid=15
不知道哪里错了

解决方案 »

  1.   

    update u set classname=(select classname from productclass pr where  
                                       pr.classid=u.classid)
    from user_productclass u where userid=15
      

  2.   


    update user_productclass
    set classname=(select classname from productclass pr where pr.classid=u.classid)
    from user_productclass u where userid=15试试这样行不行?
      

  3.   

    update
     b 
    set
     classname=a.classname
    from
     productclass a,user_productclass b 
    where
     a.classid=b.classid
    and
     b.userid=15