UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'm7FnbRVwHoG6XysEtGXuG3mSLmG4S58iP7e5706bCv8='
WHERE
key_id = 'b51c9e460d1d89c32d646ddfcb2c201e5a0942bf03de39c299869601bb16ee5c'
AND (
token = 'm7FnbRVwHoG6XysEtGXuG3mSLmG4S58iP7e5706bCv8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)