2
測試案例顯示錶的結構。我需要基於tab_2
和_3
一個加入tab_1
更新地址數據。更新腳本中所示的回報「缺少右括號」,我確信它指向的語法錯誤。希望得到任何幫助或指導,讓語句正確地更新基表。嘗試開發的語法從基於連接第三臺的另一個表更新值一個見下表
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);
「現代」連接語法一直在這裏自1996年以來!原始形式實際上是史前的。 – Bohemian 2013-03-06 20:30:05
謝謝。奇蹟般有效 – 2013-03-06 21:15:16