Skip to content

Instantly share code, notes, and snippets.

@jeffreyiacono
Created April 23, 2012 21:49
Show Gist options
  • Save jeffreyiacono/2474136 to your computer and use it in GitHub Desktop.
Save jeffreyiacono/2474136 to your computer and use it in GitHub Desktop.
mysql ladder
CREATE TABLE `ladder` (
`i` int(1) unsigned NOT NULL,
PRIMARY KEY (`i`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO ladder (i) VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9);
SELECT l1.i + l2.i * 10 + l3.i * 100 AS sequence
FROM ladder l1
JOIN ladder l2 ON TRUE
JOIN ladder l3 ON TRUE
ORDER BY sequence DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment