UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = '0Zx1yZA2io5yfODd0UFhA8NOuZA5ksEhodBa9iXA8s0='
WHERE
key_id = 'bd1659eaf5bd9a4c7d63fb01f21f04980e0abb6d4604feedf2b14e431a2e94a2'
AND (
token = '0Zx1yZA2io5yfODd0UFhA8NOuZA5ksEhodBa9iXA8s0='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)