DROP TABLE IF EXISTS ranges;
CREATE TABLE ranges (
id INT PRIMARY KEY,
start YEAR,
end YEAR,
UNIQUE KEY range_key(start, end)
);
INSERT INTO ranges VALUES (1, 1901, 2012);
INSERT INTO ranges VALUES (2, 1901, 2155);
INSERT INTO ranges VALUES (3, 2012, 2155);
INSERT INTO ranges VALUES (4, 2155, 1901);
SELECT start, end
FROM ranges FORCE INDEX(range_key)
ORDER BY start, end;
start	end
1901	2012
1901	2155
2012	2155
2155	1901
DROP TABLE ranges;
