CREATE TABLE IF NOT EXISTS items ( id INT AUTO_INCREMENT PRIMARY KEY, item_no VARCHAR(255) NOT NULL );
INSERT INTO items(item_no) VALUES ('1'), ('1C'), ('10Z'), ('2A'), ('2'), ('3C'), ('20D');
SELECT item_no FROM items ORDER BY item_no;
SELECT CONCAT(prefix, suffix) FROM items ORDER BY prefix , suffix;
SELECT item_no FROM items ORDER BY CAST(item_no AS UNSIGNED) , item_no;
TRUNCATE TABLE items; INSERT INTO items(item_no) VALUES('A-1'), ('A-2'), ('A-3'), ('A-4'), ('A-5'), ('A-10'), ('A-11'), ('A-20'), ('A-30');
SELECT item_no FROM items ORDER BY LENGTH(item_no) , item_no;