use test; DROP TABLE IF EXISTS test; CREATE TABLE test ( ID_test varchar(10) binary NOT NULL default '', foo tinyint(1) unsigned NOT NULL default '0', PRIMARY KEY (ID_test), KEY foo (foo) ) TYPE=MyISAM PACK_KEYS=1; INSERT INTO test (ID_test, foo) VALUES ('0000000010', 0), ('000000000Z', 0), ('000000001d', 0), ('000000001b', 0), ('000000001e', 0), ('000000000T', 0), ('000000000P', 0), ('0000000019', 0), ('0000000011', 1), ('000000000X', 1), ('000000000c', 0), ('000000000O', 0), ('000000000a', 0), ('000000000k', 0), ('0000000002', 1), ('000000001m', 0), ('0000000007', 0), ('000000000W', 0), ('000000001c', 1), ('0000000009', 0), ('000000000r', 0), ('000000000s', 1), ('0000000017', 0), ('000000001a', 0), ('000000001i', 0), ('000000001g', 0), ('000000001h', 0), ('000000001r', 0), ('000000001p', 0), ('000000001l', 0), ('000000001n', 0), ('000000001o', 0), ('000000001q', 0), ('000000001t', 0), ('000000001s', 0), ('000000001u', 0), ('000000001v', 0), ('000000001w', 0), ('000000001x', 0), ('000000001y', 0), ('000000001A', 0), ('000000001z', 0), ('000000001B', 0), ('000000001G', 0), ('000000001C', 0), ('000000001D', 0), ('000000001E', 1), ('000000001F', 0), ('000000001U', 0), ('000000001H', 0), ('000000001I', 0), ('000000001J', 0), ('000000001K', 0), ('000000001L', 0), ('000000001M', 0), ('000000001N', 0), ('000000001S', 0), ('000000001T', 0), ('000000002b', 1), ('0000000022', 0), ('0000000021', 0), ('000000001V', 0), ('000000001W', 0), ('000000001X', 0), ('000000001Y', 0), ('0000000025', 0), ('0000000026', 0), ('0000000027', 0), ('0000000028', 0), ('000000002d', 1), ('0000000029', 0), ('000000002a', 0), ('000000002g', 1), ('000000002c', 0), ('000000002k', 0), ('000000002e', 1), ('000000002h', 1), ('000000002j', 0), ('000000002l', 0), ('000000002m', 1), ('000000002q', 0), ('000000002p', 0), ('000000002x', 0), ('000000002r', 1), ('000000002u', 0), ('000000002v', 1), ('000000002w', 0), ('000000002z', 0), ('000000002y', 1); SELECT * FROM test ORDER BY foo DESC LIMIT 0, 15; # ID_test foo # 000000002y 1 # 000000002v 1 # 000000002r 1 # 000000002m 1 # 000000002h 1 # 000000002e 1 # 000000002g 1 # 000000002d 1 # 000000002b 1 # 000000001E 1 # 000000000s 1 # 000000001c 1 # 0000000002 1 # 000000000X 1 # 0000000011 1 SELECT * FROM test ORDER BY foo DESC LIMIT 15, 15; # ID_test foo # 000000002z 0 # 000000002w 0 # 000000002u 0 # 000000002x 0 # 000000002p 0 # 000000002q 0 # 000000002l 0 # 000000002j 0 # 000000002k 0 # 000000002c 0 # 000000002a 0 # 0000000029 0 # 0000000028 0 # 0000000027 0 # 0000000026 0 SELECT * FROM test ORDER BY foo DESC LIMIT 30, 15; # ID_test foo # 0000000025 0 # 000000001Y 0 # 000000001X 0 # 000000001W 0 # 000000001V 0 # 0000000021 0 # 0000000022 0 # 000000001T 0 # 000000001S 0 # 000000001N 0 # 000000001M 0 # 000000001L 0 # 000000001K 0 # 000000001J 0 # 000000001I 0 SELECT * FROM test ORDER BY foo DESC LIMIT 45, 15; # ID_test foo # 000000001H 0 # 000000001U 0 # 000000001F 0 # 000000001D 0 # 000000001C 0 # 000000001G 0 # 000000001B 0 # 000000001z 0 # 000000001A 0 # 000000001y 0 # 000000001x 0 # 000000001w 0 # 000000001v 0 # 000000001u 0 # 000000001s 0 SELECT * FROM test ORDER BY foo DESC LIMIT 60, 15; # ID_test foo # 000000001t 0 # 000000001q 0 # 000000001o 0 # 000000001n 0 # 000000001l 0 # 000000001p 0 # 000000001r 0 # 000000001h 0 # 000000001g 0 # 000000001i 0 # 000000001a 0 # 0000000017 0 # 000000000r 0 # 0000000009 0 # 000000000W 0 SELECT * FROM test ORDER BY foo DESC LIMIT 75, 15; # ID_test foo # 000000001B 0 # 000000001G 0 # 000000001C 0 # 000000001v 0 # 000000001u 0 # 000000001r 0 # 000000001p 0 # 000000001l 0 # 000000001n 0 # 000000001o 0 # 000000001q 0 # 000000001t 0 # 000000001s 0 # 000000001D 0