aboutsummaryrefslogtreecommitdiff
path: root/contrib/scripts/update_updated.sql
blob: 39b292105418ba968becd3696ec14c291a95a4fc (plain) (blame)
1
2
UPDATE messages, (SELECT messages.`message_id` midd, MAX(COALESCE(replies.ts, messages.ts)) lastt  FROM messages LEFT JOIN replies ON messages.`message_id`=replies.`message_id` GROUP BY messages.`message_id`) res
SET messages.updated = res.lastt WHERE messages.`message_id` = res.midd ;