Ver originalSET @mitad = 304; SELECT T.cod, T.nombre FROM( SELECT cod, nombreFROM fotosORDER BY ABS(cod - @mitad) LIMIT 7) TORDER BY T.cod DESC;