Ver Mensaje Individual
  #11 (permalink)  
Antiguo 19/05/2009, 12:14
Avatar de huesos52
huesos52
Colaborador
 
Fecha de Ingreso: febrero-2009
Ubicación: Manizales - Colombia
Mensajes: 5.980
Antigüedad: 15 años, 2 meses
Puntos: 360
Respuesta: Hacer update que incremente el valor de un campo en funcion de otro campo

Lo que te digo es que no cierres el ultimo if dos veces con num_orden.

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))
where
id_usuario='927'
AND
estado='1'
AND
(DATE(fechapublicacion) >='2008-10-01' AND DATE(fechapublicacion) <= '2008-10-31')

Fijate que solo se cierra el else en el ultimo if. Todo el ultimo if es el else del segundo if. Y el segundo if es el else del primer if.
Por eso se debe cerrar una sola vez.
__________________
Without data, You are another person with an opinion.
W. Edwads Deming