Ver Mensaje Individual
  #10 (permalink)  
Antiguo 19/05/2009, 11:01
ciberpata
 
Fecha de Ingreso: junio-2003
Ubicación: Santiago de Compostela
Mensajes: 603
Antigüedad: 20 años, 10 meses
Puntos: 0
Respuesta: Hacer update que incremente el valor de un campo en funcion de otro campo

Lo he hecho tal como dices:

update
ofertas
set
num_orden=if(
(round(TO_DAYS(ofertas.fechaexpiracion ) - TO_DAYS( date( ofertas.fechapublicacion ) ))/7) between '1' and '4',(1 + ROUND(RAND() * (5 - 1))),
if(
(round(TO_DAYS(ofertas.fechaexpiracion ) - TO_DAYS( date( ofertas.fechapublicacion ) ))/7) between '4' and '8',(6 + ROUND(RAND() * (9 - 6))),
if((round(TO_DAYS(ofertas.fechaexpiracion ) - TO_DAYS( date( ofertas.fechapublicacion ) ))/7) between '8' and '12',(10 + ROUND(RAND() * (15 - 10))),num_orden),num_orden))
where
id_usuario='927'
AND
estado='1'
AND
(DATE(fechapublicacion) >='2008-10-01' AND DATE(fechapublicacion) <= '2008-10-31')

y me devuelve error en la linea que pongo en rojo:
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'num_orden))
__________________

Espero haber aprendido algo de tí.
A mi padre.