mysql データが無ければINSERT、あればUPDATEする

mysql データが無ければINSERT、あればUPDATEする

https://php.programmer-reference.com/mysql-mysql-merge/


    INSERT INTO customer_spa (mail, customer, tag)
    VALUES ('test1@test.com', 0, 0), ('aaa@test.com', 0, 0)
    ON DUPLICATE KEY UPDATE customer=0, tag=0;


MySQL なければINSERT、あればスキップ(IGNORE)


    INSERT IGNORE INTO customer_spa (mail, customer, tag)
    VALUES ('test1@test.com', 0, 1), ('aaa@test.com', 0, 1);