Reputation: 813
Hi I am trying to run query to update my oracle table .Following is the code
UPDATE analysis_oracle_upd t1
SET
(c)
=
(SELECT t2.c FROM analysis_oracle_upd2 WHERE t1.a = t2.a
)
WHERE EXISTS
(SELECT 1 FROM analysis_oracle_upd2 t2 WHERE t1.a=t2.a
);
But I am getting this exception :
SQL Error: ORA-00904: "T2"."A": invalid identifier
00904. 00000 - "%s: invalid identifier"
Following is the schema for two tables :
create table analysis_oracle_upd (
a number(22),
c varchar(100),
primary key (a));
create table analysis_oracle_upd2 (
a number(22),
c varchar(100),
primary key (a));
Upvotes: 0
Views: 598
Reputation: 1731
You should add alias for table in your first subquery:
UPDATE analysis_oracle_upd t1
SET
(c)
=
(SELECT t2.c FROM analysis_oracle_upd2 t2 WHERE t1.a = t2.a
)
WHERE EXISTS
(SELECT 1 FROM analysis_oracle_upd2 t2 WHERE t1.a=t2.a
);
Upvotes: 2