본문 바로가기
개발/데이타베이스

INSERT, UPDATE WITH MULTI SELECT QUERY

by 로그인시러 2016. 11. 4.
INSERT INTO account_type_standard 
  (account_type_Standard_id, tax_status_id, recipient_id) 
VALUES( 
  (SELECT account_type_standard_seq.nextval FROM DUAL),
  (SELECT tax_status_id FROM tax_status WHERE tax_status_code = ?), 
  (SELECT recipient_id FROM recipient WHERE recipient_code = ?)
)


출처 : http://stackoverflow.com/questions/131164/oracle-insert-via-select-from-multiple-tables-where-one-table-may-not-have-a-row


UPDATE TEST
SET 
COL1 = (SELECT COUNT(*) FROM TEST1 WHERE ID =1),
COL2 = (SELECT COUNT(*) FROM TEST2 WHERE ID =1)
WHERE ID = 1;


'개발 > 데이타베이스' 카테고리의 다른 글

oracle auto increment  (0) 2016.11.28
group by, orderby, multiple column  (0) 2016.11.11
ORACLE LEFT OUTER JOIN  (0) 2016.11.08
오라클 세션 관련  (0) 2016.11.02
tibero drop table (wildcard 로 지우기)  (0) 2016.10.26

댓글