Skip navigation links

MySQL Forums :: Spanish :: Update Select


Advanced Search

Update Select
Posted by: Gabriel Delestal ()
Date: July 06, 2012 08:10AM

Necesito ayuda!
tengo que Actualizar un campo de una tabla, utilizando la misma tabla.

ejemplo

tabla dbs
fecha
hora
numero
interno
duracion
codigo

tengo el registro
fecha hora interno nro duracion codigo
2012-07-04 15:10 104 846359878 00:01:55 1234
2012-07-04 15:12 104 46359878 00:02:05


el campo fecha interno son iguales, el numero es el mismo (pero sin el 8 adelante)
hay que agregar el codigo al que no lo tiene..


yo hice..

update dbs
set codigo=(select dr1.Codigo
from dr as dr1, dr as dr2
where dr1.Numero like '8%'and mid(dr1.Numero,2)=dr2.Numero and dr1.Interno=dr2.interno and dr1.Fecha=dr2.Fecha and dr1.Hora>=dr2.hora)
where exists
(select dr1.Codigo
from dr as dr1, dr as dr2
where dr1.Numero like '8%'and mid(dr1.Numero,2)=dr2.Numero and dr1.Interno=dr2.interno and dr1.Fecha=dr2.Fecha and dr1.Hora>=dr2.hora)


pero no funciona... alguna idea?

Options: ReplyQuote


Subject Views Written By Posted
Update Select 2206 Gabriel Delestal 07/06/2012 08:10AM
Re: Update Select 703 laptop alias 07/08/2012 06:54PM


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.