Quantcast
Channel: MySQL Forums - Microsoft SQL Server
Viewing all articles
Browse latest Browse all 686

Can this be done in one select? (no replies)

$
0
0
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

Viewing all articles
Browse latest Browse all 686

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>