MySQL Forums
Forum List  »  Spanish

como unir estas dos consultas
Posted by: esteban cuezzo
Date: December 16, 2010 03:46PM

esta consulta me devuelve un valor el cual lo quuiero actuaclizar en la tabla1

select sum(cantidad*precio) as subtotal from Tabla2 where Tabala2.idtabla1='23'

update tabala1 set tabla1.subtotal=("el resultado de lo anterior") where idtabla1='23'

el campo Tabala2.idtabla1 se repite
el campo Tabala1.idtabla1 NO se repite es la clave primaria

si se puede en un SP mejor intente poner esto pero sale error

create procedure actualizar (in parametro varchar(45))

update tabala1 set tabla1.subtotal=(select sum(cantidad*precio) as subtotal from Tabla2 where Tabala2.idtabla1=parametro) where idtabla1=parametro

gracias desde ya

Options: ReplyQuote


Subject
Views
Written By
Posted
como unir estas dos consultas
2853
December 16, 2010 03:46PM
801
December 16, 2010 05:36PM


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.