공부
[MySQL] INSERT ... ON DUPLICATE KEY UPDATE ...
승가비
2022. 8. 31. 15:37
728x90
INSERT INTO lee(exp_id, created_by, location, animal, starttime, endtime, entct,
inact, inadur, inadist,
smlct, smldur, smldist,
larct, lardur, lardist,
emptyct, emptydur)
SELECT id, uid, t.location, t.animal, t.starttime, t.endtime, t.entct,
t.inact, t.inadur, t.inadist,
t.smlct, t.smldur, t.smldist,
t.larct, t.lardur, t.lardist,
t.emptyct, t.emptydur
FROM tmp t WHERE uid=x
ON DUPLICATE KEY UPDATE entct=t.entct, inact=t.inact, ...
https://stackoverflow.com/questions/2472229/insert-into-select-from-on-duplicate-key-update
INSERT INTO ... SELECT FROM ... ON DUPLICATE KEY UPDATE
I'm doing an insert query where most of many columns would need to be updated to the new values if a unique key already existed. It goes something like this: INSERT INTO lee(exp_id, created_by, ...
stackoverflow.com
https://devlog-wjdrbs96.tistory.com/365
[MySQL] Upsert 쿼리란 무엇일까?
MySQL Upsert 사용법 이번 글에서는 MySQL 에서 Upsert 쿼리를 사용하는 법에 대해서 정리해보겠습니다. Upsert는 이름에서 어느정도 유추할 수 있듯이 Update + Insert 를 합친 말입니다. 즉, Upsert는 중복되
devlog-wjdrbs96.tistory.com
728x90