この方法を試してください:
UPDATE Table1 t1
JOIN (
SELECT `PrimaryId`,
`SecondaryId`,
(SELECT count(*)
FROM Table1 t1
WHERE t1.`SecondaryId` = t.`SecondaryId`
AND t1.`PrimaryId` <= t.`PrimaryId`
) `Order`
FROM Table1 t
) t2
ON t1.`PrimaryId` = t2.`PrimaryId`
SET t1.`Order` = t2.`Order`
;
デモ->