
ORACLE修改关联表的语句 15
Oracle数据中,现有两个表,bill,suppliergoodsnumber,billid,supplierid是表名bill中的列;supplierid是表bill...
Oracle数据中,现有两个表,bill,supplier
goodsnumber,billid,supplierid是表名bill中的列;
supplierid是表bill的外键,supplier的主键
suppliername是通过supplierid关联查询到的列
现在的需求是关联修改suppliername,以下语句执行修改,无法保存,请大家指点,谢谢!
String sql="update (select b.*,s.suppliername,rownum rr from bill b,supplier s where s.supplierid=b.supplierid) set goodsnumber=?,suppliername=? where billid=?";
修改后
update bill b set goodsname='汽车配件',torvover='5000'
where billid=6
and exists(select suppliername from supplier s where s.supplierid=b.supplierid and s.suppliername='阿里巴巴'
另外我要同时修改suppliername,是不是这样写就可以了?
update bill set goodsname='汽车配件',torvover='5000',suppliername='百度'~~后面的不变 展开
goodsnumber,billid,supplierid是表名bill中的列;
supplierid是表bill的外键,supplier的主键
suppliername是通过supplierid关联查询到的列
现在的需求是关联修改suppliername,以下语句执行修改,无法保存,请大家指点,谢谢!
String sql="update (select b.*,s.suppliername,rownum rr from bill b,supplier s where s.supplierid=b.supplierid) set goodsnumber=?,suppliername=? where billid=?";
修改后
update bill b set goodsname='汽车配件',torvover='5000'
where billid=6
and exists(select suppliername from supplier s where s.supplierid=b.supplierid and s.suppliername='阿里巴巴'
另外我要同时修改suppliername,是不是这样写就可以了?
update bill set goodsname='汽车配件',torvover='5000',suppliername='百度'~~后面的不变 展开
2个回答
展开全部
update更新表不能用重命名
update bill set goodsname='汽车配件',torvover='5000'
where billid=6
and exists (select suppliername from supplier s where s.supplierid=bill.supplierid and s.suppliername='阿里巴巴')
update bill set goodsname='汽车配件',torvover='5000'
where billid=6
and exists (select suppliername from supplier s where s.supplierid=bill.supplierid and s.suppliername='阿里巴巴')
追问
我的理解是,当执行(select suppliername from supplier s where s.supplierid=bill.supplierid and s.suppliername='阿里巴巴')这个条件后,update是在符合条件的新表里进行的,现在修改的数据,在原来的bill里是不会变的,
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询