1

I've got this code(it works):

update CES.SCHEME_ELEMENT se
set se.NAME = (
select ni.NAME_WT from CES.NI_CES ni
where se.FK_VALUE = ni.ID_NI_WORK and 
se.SCHEME_ID = 11 and se."TYPE" = 'zn' );

And don't understand, why I can't do something like this

update CES.NI_CES ni
set ni.NAME_WT = 'ЗР'
where ni.ID_NI_WORK = (
select se.FK_VALUE from CES.SCHEME_ELEMENT se
where  se.SCHEME_ID = 11 and se."TYPE"='zn');

OR

UPDATE
(SELECT ni.NAME_WT nw
 FROM CES.NI_CES ni
 INNER JOIN CES.SCHEME_ELEMENT se
 ON se.FK_VALUE = ni.ID_NI_WORK
 WHERE se.SCHEME_ID = 11 and se."TYPE"='zn'
) t
SET t.nw = 'ЗР';

Saw this Update statement with inner join on Oracle

Thnks

Community
  • 1
  • 1
Artem.Borysov
  • 1,031
  • 2
  • 12
  • 29

1 Answers1

2

You could use the in operator instead of the = operator for the sub query:

update CES.NI_CES ni
set ni.NAME_WT = 'ЗР'
where ni.ID_NI_WORK IN ( --HERE!
select se.FK_VALUE 
from CES.SCHEME_ELEMENT se
where  se.SCHEME_ID = 11 and se."TYPE"='zn');
Mureinik
  • 297,002
  • 52
  • 306
  • 350