MySQL Forums
Forum List  »  Microsoft SQL Server

Can this be done in one select?
Posted by: Roberto Cano Ramos
Date: January 26, 2012 04:22AM

Hi,
I want to do this on just one update

create temporary table roberto
as
(

select
p.ID,
(select id from financial where tipo=2 and id_paciente=p.id_paciente and fecha=p.fecha and isnull(id_cargo) ) as cual
from financial p
where p.tipo=1 );

update financial set id_cargo=(select cual from roberto where id=financial.id );


drop table roberto;

I have tried this without luck:

update financial p set p.id_cargo=(select id from financial where tipo=2 and id_paciente=p.id_paciente and fecha=p.fecha and isnull(id_cargo) )
where p.tipo=1;

Hope to lean something out of this....
Thank

Roberto

Options: ReplyQuote


Subject
Written By
Posted
Can this be done in one select?
January 26, 2012 04:22AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.