Ver Mensaje Individual
  #4 (permalink)  
Antiguo 16/11/2010, 16:16
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: Obtener los últimos 5 valores de una tabla en orden (con PHP)

Si entendí bien es algo mas o menos así:

Código MySQL:
Ver original
  1. mysql> select *from ordenamiento;
  2. +------+
  3. | id   |
  4. +------+
  5. |    1 |
  6. |    2 |
  7. |    3 |
  8. |    4 |
  9. |    5 |
  10. |    6 |
  11. |    7 |
  12. |    8 |
  13. +------+
  14. 8 rows in set (0.00 sec)
  15.  
  16. mysql> select *from ordenamiento order by 1 desc limit 5;
  17. +------+
  18. | id   |
  19. +------+
  20. |    8 |
  21. |    7 |
  22. |    6 |
  23. |    5 |
  24. |    4 |
  25. +------+
  26. 5 rows in set (0.02 sec)
  27.  
  28. mysql> SELECT *FROM (select *from ordenamiento order by 1 desc limit 5) t order by 1 asc;
  29. +------+
  30. | id   |
  31. +------+
  32. |    4 |
  33. |    5 |
  34. |    6 |
  35. |    7 |
  36. |    8 |
  37. +------+
  38. 5 rows in set (0.00 sec)
  39.  
  40. mysql>
__________________
Without data, You are another person with an opinion.
W. Edwads Deming