我想将B表中的值替换A表中的值,前提是A.no=B.no,请问该如何做?

[复制链接]
查看11 | 回复5 | 2006-4-13 07:34:50 | 显示全部楼层 |阅读模式
我想将B表中的值替换A表中的值,前提是A.no=B.no
update B set B.sl=A.sl where A.no=B.no
提示:错误的列名。应该是说不认A.sl,请问该如何做?谢谢
回复

使用道具 举报

千问 | 2006-4-13 07:34:50 | 显示全部楼层
update B
set B.sl=(select A.sl from A where A.no=B.no)
回复

使用道具 举报

千问 | 2006-4-13 07:34:50 | 显示全部楼层
同意
回复

使用道具 举报

千问 | 2006-4-13 07:34:50 | 显示全部楼层
另外还有一个问题(总是不能解决两个表间的关系)
insert into B(nob) select noa from A;将A表内容插入B表没问题
我想做的是只插入A.noa=B.nob的记录
insert into B(nob) select noa from A where A.noa=B.nob;
提示B.nob为无效列名。
delelte B where B.nob=A.noa删除B表中B.nob=A.noa也是这个问题
回复

使用道具 举报

千问 | 2006-4-13 07:34:50 | 显示全部楼层
用update吧
回复

使用道具 举报

千问 | 2006-4-13 07:34:50 | 显示全部楼层
这样更新不对吧
如果 A.noa!=B.nob 的行会把B.sl 设为null
[email protected] >update emp set ename=(select dname from dept where dept.deptno=emp.deptno)
2where exists ( select deptno from dept where dept.deptno=emp.deptno);
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行