请问批量更新这个sql怎么写?

andrew064 2007-11-08 12:02:22
description 表格 字段 proid, langid,name,des,model,view

INSERT 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到复制空的字段

请教了,谢谢!
...全文
40 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
andrew064 2007-11-08
  • 打赏
  • 举报
回复
谢谢啦
第一楼可以

第二楼好像不行,

#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

不过还是谢谢啦
ojuju10 2007-11-08
  • 打赏
  • 举报
回复

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
懒得去死 2007-11-08
  • 打赏
  • 举报
回复

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;

56,678

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧