반응형

'ASC'에 해당되는 글 1건

  1. 2017.11.29 MySQL 조건에 일치하는 레코드 복사하기.
반응형

MySQL 조건에 일치하는 레코드 복사하기.

 

MySQL 특정 레코드만 복사하기.

 

table_01 age 컬럼의 40이상인 레코드만 복사해서 새로운 테이블 table_ageOver40 을 생성해 보겠습니다.

 

create table table_ageOver40

select * from table_01

where age >= 40 and age < 50;

 

select * from table_ageOver40;

 

기존에 존재하는 테이블에 레코드를 추가하는 경우에는 insert into를 사용합니다.

Table_01에 있는 Age 50이상인 레코드를 table_ageOver40 에 추가해 보겠습니다.

 

insert into table_ageOver40

select * from table_01 where age >= 50;

 

select * from table_ageOver40;

A6 이수만 60 레코드가 잘 추가 되었습니다.

 

 

MySQL 순서대로 정렬하여 복사하기

table_01age컬럼을 올림차순으로 정렬한 후 4번째부터 5개의 레코드를 복사하여 table_age4To8 테이블을 생성해 보겠습니다.

 

create table table_age4To8

select * from table_01 order by age asc

limit 5 offset 3;

 

select * from table_age4To8;

 

반응형
Posted by 컴스터
,


반응형