SELECT CONCAT("SET @row = 0; INSERT INTO FILE_ITEM_ORDER (KEY_PARENT, KEY_FILE_ITEM, ITEM_ORDER) SELECT FILE.KEY_ITEM, FILE.ID_INTERNAL, @row := @row + 1 FROM FILE WHERE FILE.KEY_ITEM = ", CONTENT.ID_INTERNAL, " ORDER BY FILE.UPLOAD_TIME;") AS ""
FROM CONTENT WHERE CONTENT.OJB_CONCRETE_CLASS LIKE "%.Item";
