description 表格 字段 proid, langid,name,des,model,viewINSERT INTO `description` VALUES (7, 15, 'dddd', 'ddddd', 'dddd', 0);
INSERT INTO `description` VALUES (7, 16, '', '', '', 0);
INSERT INTO `description` VALUES (7, 17, '', '', '', 0);
INSERT INTO `description` VALUES (7, 18, '', '', '', 0);
INSERT INTO `description` VALUES (8, 2, 'dddd', 'dddd', 'dddd', 0);
INSERT INTO `description` VALUES (8, 3, '', '', '', 0);
INSERT INTO `description` VALUES (8, 4, '', '', '', 0);现在更新如下
相同proid, langid不同的,从非空name,des,model,view到复制空的字段请教了,谢谢!

解决方案 »

  1.   


    create temporary table tmp select * from description group by proid;
    update description a,tmp b set a.name = b.name,a.des=b.des,a.model=b.model where a.proid = b.proid and a.langid != b.langid;
    drop table tmp;
      

  2.   


    update a set a.name=b.name ,a.dec=b.dec , a.model=b.model
    from (select * from description where name ='') a ,(select * from description where name <>'') b
    where a.proid=b.proid
      

  3.   

    谢谢啦
    第一楼可以第二楼好像不行,#1064 - You have an error in your SQL syntax.  Check the manual that corresponds to your MySQL server version for the right syntax to use near 'from (select * from description where name不过还是谢谢啦