当前位置: 代码迷 >> Oracle管理 >> update语句出错,求指正解决方法
  详细解决方案

update语句出错,求指正解决方法

热度:204   发布时间:2016-04-24 06:19:44.0
update语句出错,求指正
update t_marketset t_market.tellername=t_teller.name where t_market.tellerid=t_teller.id;
报错
ORA-00904: "t_teller"."id": 标识符无效;

但是
select t_teller.id from t_teller ;却能够查出记录。
why? 出错



------解决方案--------------------
两张表没连接关系
update t_market set tellername=(select name from t_teller where id=t_market.tellerid);
------解决方案--------------------
探讨
update t_marketset t_market.tellername=t_teller.name where t_market.tellerid=t_teller.id;
报错
ORA-00904: "t_teller"."id": 标识符无效;

但是
select t_teller.id from t_teller ;却能够查出记录。
why? 出错

------解决方案--------------------
update t_market
set t_market.tellername = t_teller.name
 where exists
 (select 1 from t_teller where t_teller.id = t_market.tellerid);
  相关解决方案