JiYoung Dev 🖥

[database 고급] merge (2023.08.08) 본문

full stack/database

[database 고급] merge (2023.08.08)

Shinjio 2023. 8. 8. 15:49

 

 

-- MERGE
MERGE INTO TB_CUST_TEL
USING DUAL
   ON ( CUST_ID = 'C0007' AND TEL_DVCD = '휴대폰')
WHEN MATCHED THEN
UPDATE 
   SET TEL_NO = '010-7777-7777'
WHEN NOT MATCHED THEN
INSERT (CUST_ID, TEL_DVCD, TEL_NO)
VALUES ('C0007', '휴대폰', '010-7777-7777');

SELECT * FROM TB_CUST_TEL;