update (select tb_spec.attribute2,tb_spec.attribute1
from tb_spec join tb_storage on tb_spec.spec_id=tb_storage.spec_id
where tb_storage.storage_id=47445)
set attribute2='张飞',attribute1='韩国'
执行的出错信息是:无法修改与非键值保存表对应的列
其中tb_spec和tb_storage都是表,不是视图.
他们都有自己的主键,tb_spec的是spec_id,tb_storage的是storage_id.
---------------------------------------------------------------
跟主表的主键没关系,应该是从表的tb_storage.spec_id 没有主键约束条件,你这么写不行,换种写法试试:
update tb_spec a
set attribute2='张飞',attribute1='韩国'
where exists
(select 1 from tb_storage where a.spec_id=b.spec_id and b.storage_id=47445)
---------------------------------------------------------------
update 可以更新视图的,但前提是关联到的从表的字段必须有主键约束
---------------------------------------------------------------
楼主可以看看这里:
http://community.csdn.net/Expert/topic/4158/4158385.xml?temp=.8785364