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 'ORDER BY control_cambio_fecha_hora desc LIMIT 1' at line 8->SELECT codigo_recuperacion,
date(control_cambio_fecha_hora) as fecha,
time(control_cambio_fecha_hora) as hora,
EXTRACT(hour FROM TIMEDIFF(NOW(), control_cambio_fecha_hora)) as horas
from control_cambio
WHERE codigo_recuperacion = ''
and date(control_cambio_fecha_hora) = CURDATE()
and usuario_codigo= ORDER BY control_cambio_fecha_hora desc LIMIT 1;