mardi 19 juillet 2016

ORACLE SQL: how to update a table based in another column?

So, i have two tables, INTERNAMENTO and DOC_ADMISSAO2. i want to update a column from table INTERNAMENTO named DIASINTERNAMENTO with the same values of the table DOC_ADMISSAO2 called DIASADMISSAO, with some conditions..

update INTERNAMENTO a
set a.DIASINTERNAMENTO = (
       select b.DIASADMISSAO
       from DOC_ADMISSAO2 b
       where (a.EPISODIO = b.EPISODIO) AND (a.DATACRIACAO <= b.DATACRIACAO));

It gives me an error:

  1. 00000 - "single-row subquery returns more than one row"

Any advice?

Aucun commentaire:

Enregistrer un commentaire