mysql insert on dupèlicate
INSERT INTO table_name(c1)
VALUES(c1)
ON DUPLICATE KEY UPDATE c1 = VALUES(c1) + 1;
mysql insert on dupèlicate
INSERT INTO table_name(c1)
VALUES(c1)
ON DUPLICATE KEY UPDATE c1 = VALUES(c1) + 1;
update after insert sql
-- SQL Server (update my_table2 after insert on my_table1)
CREATE TRIGGER trigger_name ON my_table1 FOR INSERT AS
BEGIN
UPDATE my_table2 SET my_col_date = getdate() FROM my_table1
END
-- Oracle (insert into log table after update on my_table)
CREATE OR REPLACE TRIGGER trigger_name AFTER INSERT ON my_table
FOR EACH ROW
BEGIN
INSERT INTO my_log_table (LOG_DATE, ACTION) VALUES (SYSDATE, 'Changed');
END;
sql insert or update
-- Oracle: Example for Insert or update in t1 from t2 values
MERGE INTO table1 t1
USING table2 t2
ON (t1.CODE = t2.ID)
WHEN MATCHED THEN
UPDATE SET t1.COL1 = t2.VALUE1
WHEN NOT MATCHED THEN
INSERT (CODE, COL1) VALUES (t2.ID, t2.VALUE1);
-- MySql (makes a INSERT + DELETE if existing)
REPLACE INTO table1 (pk_id, col1) VALUES (5, 'aaaa');
--
INSERT INTO table1 VALUES (key, generation)
ON DUPLICATE KEY UPDATE (key = key, generation = generation + 1);
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us