有两个表personal_pat_master_index 和personal_pat_master_index1 两个表中关联字段是身份证, 我要把两个表中身份证相同的 personal_pat_master_index的数据,修改为personal_pat_master_index1的数据,我是这样写的update personal_pat_master_index p,community.personal_pat_master_index1 p1
set p.work_units = p1.work_units,
p.phoneself = p1.phoneself,
p.next_of_kin = p1.next_of_kin,
p.next_of_kin_phone = p1.next_of_kin_phone,
p.usualtype = p1.usualtype,
p.nation = p1.nation,
where p.id_no = p1.id_no
and p1.community_Code = '431028001' and p1.community_code=p.community_code说缺失SET关键 在update personal_pat_master_index p,community.personal_pat_master_index1 p1
逗号这
set p.work_units = p1.work_units,
p.phoneself = p1.phoneself,
p.next_of_kin = p1.next_of_kin,
p.next_of_kin_phone = p1.next_of_kin_phone,
p.usualtype = p1.usualtype,
p.nation = p1.nation,
where p.id_no = p1.id_no
and p1.community_Code = '431028001' and p1.community_code=p.community_code说缺失SET关键 在update personal_pat_master_index p,community.personal_pat_master_index1 p1
逗号这
解决方案 »
- oracle的一个问题,请大虾们帮个忙。
- 这个sql如何写?
- why? 简单的to_date 函数 怎么会出现这么大的诧异
- SSIS中,连结管理器无法连接到服务器的ORACLE数据库
- oracle存储过程动态参数如何编写及如何引用动态参数
- 安装oracle10G服务器端后无法登陆?即使用system/sys也(ORA-01017:invalid username/password;)
- 如何写一个触发器?
- oracle enterprise manager 10g
- 关于LONG型字段的处理问题
- 下列SQL语句有什么问题,请帮忙修改一下,万分感激。
- 如何按月建立分区
- 紧急求助,有没有将SQL Server的SQL翻译为Oracle的第三方组件?
update personal_pat_master_index p
set (p.work_units,
p.phoneself,
p.next_of_kin,
p.next_of_kin_phone,
p.usualtype,
p.nation
)=
(
select p1.work_units,
p1.phoneself,
p1.next_of_kin,
p1.next_of_kin_phone,
p1.usualtype,
p1.nation
from community.personal_pat_master_index1 p1
where p.id_no = p1.id_no
and p1.community_Code = '431028001' and
p1.community_code=p.community_code
)
--改正了一下
update personal_pat_master_index p
set (p.work_units,
p.phoneself,
p.next_of_kin,
p.next_of_kin_phone,
p.usualtype,
p.nation)
=
(
select p1.work_units,
p1.phoneself,
p1.next_of_kin,
p1.next_of_kin_phone,
p1.usualtype,
p1.nation
from personal_pat_master_index1 p1
where p.id_no = p1.id_no and
p1.community_Code = '431028001' and
p1.community_code=p.community_code
)
where exits(
select p1.work_units,
p1.phoneself,
p1.next_of_kin,
p1.next_of_kin_phone,
p1.usualtype,
p1.nation
from personal_pat_master_index1 p1
where p.id_no = p1.id_no)
上面那个不可以吗?
试试这个
update personal_pat_master_index
set (work_units,
phoneself,
next_of_kin,
next_of_kin_phone,
usualtype,
nation)=(
select work_units,
phoneself,
next_of_kin,
next_of_kin_phone,
usualtype,
nation
from personal_pat_master_index1)
where exits(
select 1
from personal_pat_master_index p,
personal_pat_master_index1 p1
where p.id_no = p1.id_no)
merge into personal_pat_master_index p
using community.personal_pat_master_index1 p1
on (p.id_no = p1.id_no)
when matched then
update set p.work_units = p1.work_units,
p.phoneself = p1.phoneself,
p.next_of_kin = p1.next_of_kin,
p.next_of_kin_phone = p1.next_of_kin_phone,
p.usualtype = p1.usualtype,
p.nation = p1.nation================================================
--如楼上兄台说的,更新关联表,常用oracle 9i引入的merge语句:
merge into personal_pat_master_index p
using personal_pat_master_index1 p1
on (p.id_no=p1.id_no)
when matched then
update
set p.work_units = p1.work_units,
p.phoneself = p1.phoneself,
p.next_of_kin = p1.next_of_kin,
p.next_of_kin_phone = p1.next_of_kin_phone,
p.usualtype = p1.usualtype,
p.nation = p1.nation;
--再说,测试怎么能用正式库呢?
--另外创建两个表,如实验成功,再确定更新