おそらく、tripid は table2 で一意ではありませんか?
それはあなたの例にありますが、実際のデータでは一意ですか?
DROP table table1;
create table table1(tripid number, sequence number, pattern CHAR(1));
insert into table1 values (1,1,null);
insert into table1 values (1,2,null);
insert into table1 values (1,3,null);
insert into table1 values (2,1,null);
insert into table1 values (2,2,null);
DROP table table2;
create table table2(tripid number, pattern CHAR(1));
insert into table2 values (1,'A');
insert into table2 values (2,'B');
commit;
select table2.tripid, table2.pattern from table2,table1 where table1.tripid = table2.tripid;
update table1
set table1.pattern =
(select pattern from table2 where table1.tripid = table2.tripid)
where exists
(select pattern from table2 where table1.tripid = table2.tripid);
commit;
select * from table1;
戻り値:
Table dropped.
Table created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
Table dropped.
Table created.
1 row created.
1 row created.
Commit complete.
TRIPID PATTERN
---------- -------
1 A
1 A
1 A
2 B
2 B
5 rows selected.
5 rows updated.
TRIPID SEQUENCE PATTERN
---------- ---------- -------
1 1 A
1 2 A
1 3 A
2 1 B
2 2 B
5 rows selected.
これは、適切なデータがあれば、Oracle (およびクエリ) が完全に機能することを証明しています。
キリスト教徒