oracle修改数据语法。 属于联表查询进行修改来的。
updatetmp_09_graduategsetg.schoolid=c.c8900whereg.enrollschoolin(selectc.c8900fromc89...
update tmp_09_graduate g
set g.schoolid = c.c8900
where g.enrollschool in (select c.c8900 from c89 c); 展开
set g.schoolid = c.c8900
where g.enrollschool in (select c.c8900 from c89 c); 展开
展开全部
这样写,别名太多了,去掉了一些:
UPDATE Tmp_09_Graduate g
SET g.Schoolid =
(SELECT C8900
FROM C89
WHERE C8900 = g.Enrollschool
AND Rownum = 1)
WHERE g.Enrollschool IN (SELECT C8900 FROM C89);
UPDATE Tmp_09_Graduate g
SET g.Schoolid =
(SELECT C8900
FROM C89
WHERE C8900 = g.Enrollschool
AND Rownum = 1)
WHERE g.Enrollschool IN (SELECT C8900 FROM C89);
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
不明白,这个schoolid和enrollschool难道不是同一个值?
分析一下这个语句:
where里的SELECT子句,返回的是c.c8900,条件是enrollschool在这个返回列表里,即enrollschool和某个c8900是相同的,然后你又set schoolid=c8900,那和set schoolid=enrollschool有什么差别?(假设对于某个enrollschool只有一个C8900对应哈,不然执行会报错的)
分析一下这个语句:
where里的SELECT子句,返回的是c.c8900,条件是enrollschool在这个返回列表里,即enrollschool和某个c8900是相同的,然后你又set schoolid=c8900,那和set schoolid=enrollschool有什么差别?(假设对于某个enrollschool只有一个C8900对应哈,不然执行会报错的)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select c.c8900 from c89 c;查询的结果可能是多个值,多个值怎么可以全部赋给g.schoolid呢。
想了想,是不是可以这样做呢?
update tmp_09_graduate g
set g.schoolid = g.enrollschool
where g.enrollschool in (select c.c8900 from c89 c);
想了想,是不是可以这样做呢?
update tmp_09_graduate g
set g.schoolid = g.enrollschool
where g.enrollschool in (select c.c8900 from c89 c);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询