Mysql как сделать поле альтернативной нумерации?
Повесьте триггерDELIMITER $$
CREATE TRIGGER `items_BEFORE_INSERT` BEFORE INSERT ON `items` FOR EACH ROW
BEGIN
	DECLARE oldmax INT;
	SELECT IFNULL(MAX(`alt_id`), 0) 
		FROM `items` 
		WHERE `category_id` = NEW.`category_id` 
        INTO oldmax;
	SET NEW.`alt_id` = oldmax+1;
END$$
DELIMITER ;
Для старых:UPDATE items INNER JOIN (SELECT items.id, COUNT(joined.id) as counted_id FROM items LEFT JOIN items AS joined ON (joined.category_id = items.category_id AND joined.id <= items.id) GROUP BY items.id) as i ON items.id = i.id SET alt_id=counted_id
Для новых - ответ Rsa97