UPDATE
`orders` as `o`
SET
`diff` = (
SELECT
`created`
FROM
(
SELECT
`created`
FROM
`orders`
WHERE
`id` <> `o`.`id`
AND `client_id` = `o`.`client_id`
AND `created` <= `o`.`created`
ORDER BY
`created` DESC
LIMIT
1
) as `temp`
LIMIT
1
),
`upd` = 1
WHERE 1
UPDATE (
SELECT `t1`.`id` AS `id`, MAX(`t2`.`created`) AS `created`
FROM `orders` AS `t1`
JOIN `orders` AS `t2` ON `t2`.`client_id` = `t1`.`client_id`
AND `t2`.`id` <> `t1`.`id` AND `t2`.`created` <= `t1`.`created`
GROUP BY `t1`.`id`
) AS `t`
RIGHT JOIN `orders` AS `o` ON `o`.`id` = `t`.`id`
SET `o`.`diff` = `t`.`created`