MySQL Insert 서브 쿼리에서 한개 이상의 리턴인 경우

CREATE TABLE temp (

SELECT id, NAME

FROM USER

)

1. 서브쿼리의 반환 행이 하나인 경우

INSERT INTO temp (id, NAME) SELECT id, NAME FROM user2 WHERE id=‘coozplz’)

2. 서브쿼리의 반환 행이 하나 이상인 경우
INSERT INTO temp (id, NAME) SELECT id, NAME FROM user2

Values 를 제거 한다.

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s