使用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
3.子查询
update student s set city_name = (select name from city where code = s.city_code);
oracle查询报这个错误:single-rowsubqueryreturnsmorethanonerow怎么解决?
数据库按照你的条件查询有多个重复的数据。
例如:
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-rowsubqueryreturnsmorethanonerow的错误,说明c表”dept_name”和A表.”ROLE_NAME”的这两个字段数据重复
热门推荐
10 圣诞祝福语简短小学
11 祖国七十华诞简短祝福语
12 老师送的祝福语简短
13 生日祝福语大全女生简短
14 祝女性生日祝福语简短
15 牛年女神节祝福语简短
16 情人表白祝福语简短大气
17 老公开业祝福语简短
18 官宣新年祝福语简短