DROP TABLE IF EXISTS items;
CREATE TABLE items (
id INT PRIMARY KEY AUTO_INCREMENT NOT NULL,
prefix INT,
value TINYINT,
INDEX (prefix, value desc)
) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO items (prefix, value) VALUES(1, -126);
INSERT INTO items (prefix, value) VALUES(1, -127);
INSERT INTO items (prefix, value) VALUES(1, -127);
INSERT INTO items (prefix, value) VALUES(1, -127);
INSERT INTO items (prefix, value) VALUES(1, -128);
SELECT *
FROM items
WHERE prefix = 1 AND value > -128
ORDER BY value DESC;
id	prefix	value
1	1	-126
2	1	-127
3	1	-127
4	1	-127
DROP TABLE items;
