这很简单,但我找不到答案。如果组合确实存在,则更新,否则插入。
IF EXISTS(SELECT customer_id FROM payment_conditions WHERE customer_id = 2 AND shipping_company_id = 1)
THEN
UPDATE payment_conditions SET payment_condition = "pay in full" WHERE customer_id = 2 AND shipping_company_id = 1;
ELSE
INSERT INTO payment_conditions customer_id, shipping_company_id, payment_condition, active VALUES (2,1,"some value",1);
END IF