Так, если is_used должен быть нулевым в новой записи:
INSERT INTO promotion_1000 (
`id`,
`datetime`,
`driver_id`,
`promo_summa`,
`is_used`
)
VALUES (
'cb1b3b4d2a6ba63740fe975f29db70d8',
'2023-05-25 20:15:11',
614127,
2000,
1
) AS new
ON DUPLICATE KEY UPDATE
promo_summa = IF(new.is_used, promotion_1000.promo_summa, new.promo_summa),
`datetime` = IF(new.is_used, promotion_1000.`datetime`, new.`datetime`);
Так, если is_used должен быть нулевым в старой записи:
INSERT INTO promotion_1000 (
`id`,
`datetime`,
`driver_id`,
`promo_summa`,
`is_used`
)
VALUES (
'cb1b3b4d2a6ba63740fe975f29db70d8',
'2023-05-25 20:15:11',
614127,
2000,
1
) AS new
ON DUPLICATE KEY UPDATE
promo_summa = IF(promotion_1000.is_used, promotion_1000.promo_summa, new.promo_summa),
`datetime` = IF(promotion_1000.is_used, promotion_1000.`datetime`, new.`datetime`);