如何使用MySQL一个表中的字段更新另一个表中字段
1,修改1列
update student s, city c set s.city_name = c.name where s.city_code = c.code;
2,修改多个列
update a, b set a.title=b.title, a.name=b.name where a.id=b.id
•子查询
update student s set city_name = (select name from city where code = s.city_code);
oracle查询报这个错误:single-row subquery returns more than one row
怎么解决?
数据库按照你的条件查询有多个重复的数据。
例如:
UPDATE "SYS_ROLE" A SET A ."DEPT_ID" = ( SELECT c."id" FROM "his_department_info" c WHERE c."dept_name" = A ."ROLE_NAME"
如果以上sql语句报single-row subquery returns more than one row的错误,说明 c表”dept_name” 和A 表.”ROLE_NAME” 的这两个字段 数据重复
总结
相关推荐
herohope 2020-07-18
mrandy 2020-07-04
Jaystrong 2020-06-27
debugjoker 2020-06-17
好记忆也需烂 2020-04-21
achiverhai 2020-04-16
vivenwan 2020-04-08
要啥自行车一把梭 2020-03-20
Accpcjg 2020-02-22
要啥自行车一把梭 2020-11-12
minerk 2020-11-12
vitasfly 2020-11-12
xkorey 2020-09-14
sofia 2020-08-15
liang枫 2020-08-07
wangwtotao 2020-06-27
msmysql 2020-06-26
李高峰 2020-06-22
InJavaWeTrust 2020-06-21