2011. 8. 3. 13:44 [Major] SQL & JSP & JavaScript
update, insert문을 select로 가져와서 활용하기
- select를 활용한 update 하기
table1 업데이트할 테이블명
table2 업데이트할 데이터를 가져올 테이블명
update table1 a
set a.column1 =
( select b.column1 from table2 b
where b.column2 = 'xxx' )
where a.column3 = 'xxx';
- 같은 테이블에서 컬럼 하나만 변경하여 내용 복사해서 넣기
x=col2의 변경코자 하는 값
insert into table a (col1, col2, col3, col4 ..)
select b.col1, x, b.col3, b.col4 ..
from table b where col1='조건';
( select b.column1 from table2 b
where b.column2 = 'xxx' )
where a.column3 = 'xxx';
- 같은 테이블에서 컬럼 하나만 변경하여 내용 복사해서 넣기
x=col2의 변경코자 하는 값
insert into table a (col1, col2, col3, col4 ..)
select b.col1, x, b.col3, b.col4 ..
from table b where col1='조건';
'[Major] SQL & JSP & JavaScript' 카테고리의 다른 글
오라클에서 insert 여러개 처리하기 (0) | 2011.11.14 |
---|---|
자바스크립트 날짜 계산하기 (0) | 2011.10.12 |
토드 단축키 모음 (0) | 2011.08.09 |
SQL 함수 정리 (0) | 2011.07.11 |
오라클 테이블 복사 쿼리 (0) | 2011.07.11 |