下面的测试用例显示了表的构造。我需要tab_1
根据tab_2
和上的连接来更新地址数据_3
。显示的更新脚本返回'missing right parenthesis',我确信它指向语法错误。在获得正确更新基表的语句方面提供任何帮助或指导。
create table tab_1(address varchar2(25), city varchar2(25), state varchar2(2),zip varchar2(10), office_id varchar2(25));
create table tab_2 (company varchar2(25), office varchar2(25), address_id varchar2(5), office_id varchar2(5));
create table tab_3 (address_id varchar2(5), address varchar2(25), city varchar2(25), state varchar2(2),zip varchar2(10));
insert into tab_1(office_id) values(46);
insert into tab_2(company, office, address_id, office_id)
values('Stone', 'north', '45', '15');
insert into tab_3(address_id, address, city, state, zip)
values('15', '12Main', 'York', 'NY', '12345');
ALTER TABLE TAB_1 ADD
CONSTRAINT tab_1_PK
PRIMARY KEY (OFFICE_ID)
ENABLE
VALIDATE;
ALTER TABLE TAB_2 ADD
CONSTRAINT tab_2_PK
PRIMARY KEY (OFFICE_ID)
ENABLE
VALIDATE;
ALTER TABLE TAB_3 ADD
CONSTRAINT tab_3_PK
PRIMARY KEY (ADDRESS_ID)
ENABLE
VALIDATE;
update (select tab_3.address, tab_3.city, tab_3.state, tab_3.zip, tab_1.address, tab_1.city, tab_1.state, tab_1.zip
FROM
INNER JOIN tab_1 ON (tab_1.office_id=tab_2.office.id)
INNER JOIN tab_3 ON (tab_2.address_id = tab_3.address_id))
SET tab_1.address=tab_3.address, tab_1.city=tab_3.city, tab_1.state=tab_3.state, tab_1.zip=tab_3.zip;
UPDATE ( SELECT src.x src_x, src.y src_y , tgt.x tgt_x, tgt.y tgt_y FROM src
INNER JOIN tgt ON ( src.id = tgt.id ) ) SET tgt_x = src_x , tgt_y = src_y
*******************************************************
UPDATE tab_1
SET (address,
city,
state,
zip) =
(SELECT (address, city, state, zip)
FROM tab_3, tab2
WHERE tab_1.office_id = tab_2.office_id
AND tab_2.address_id = tab_3.address_id);