求一SQL语句,很急

Dearingsy 2007-09-16 11:51:23
我现在有两张表,table1,table2,关联的字段是id

现在是想把table2中的字段ggg更新到table1中的ggg中

请问,要怎么写

update table1 set a.ggg=b.ggg from table1 a,table2 b where a.ccid=b.ccid;

我这样写有什么错吗 ?请指教
...全文
214 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
bai_jiong 2007-09-26
  • 打赏
  • 举报
回复
要加where a.ccid=(select b.ccid from table b)这个条件,否则你会把A表中的GGG赋为同一个值的.
xiaopilakuku 2007-09-20
  • 打赏
  • 举报
回复
来晚了好像,顶下子
yifuzhiming 2007-09-19
  • 打赏
  • 举报
回复
update table1 a set a.ggg=(select b.ggg from table2 b where a.ccid=b.ccid);
47522341 2007-09-19
  • 打赏
  • 举报
回复
hebo的重复了;
直接update table1 set a.ggg=(select b.ggg from table2 b where
a.ccid=b.ccid);就可以了。
hebo2005 2007-09-18
  • 打赏
  • 举报
回复
确实可以不加的
kinglht 2007-09-17
  • 打赏
  • 举报
回复
update table1 set a.ggg=(select b.ggg from table2 b where a.ccid=b.ccid);
dengfangping 2007-09-17
  • 打赏
  • 举报
回复
hebo2005()为什么在后面还要加一句where a.ccid=(select b.ccid from table b);不

是非常理解。本人觉的update table1 set a.ggg=(select b.ggg from table2 b where

a.ccid=b.ccid);就可以了啊。
常飞梦 2007-09-17
  • 打赏
  • 举报
回复
update table1 a set a.ggg=(select b.ggg from table2 b where a.ccid=b.ccid);
hebo2005 2007-09-16
  • 打赏
  • 举报
回复
update table1 a set a.ggg= (select b.ggg from table a,table b where a.ccid=b.ccid)
where a.ccid=(select b.ccid from table b);
hebo2005 2007-09-16
  • 打赏
  • 举报
回复
有错,你这是MS SQL的写法,ORACLE不行的

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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