MySQL에서 SELECT 결과를 INSERT하기 위해 다음과 같이 할 수 있다.

CREATE TABLE data_in_second (
 time DATETIME,
 type VARCHAR(16),
 count INT(11),

 PRIMARY KEY (time, type)
);

INSERT INTO data_in_second VALUES ('2011-01-05 15:34:00', 'success', 10);
INSERT INTO data_in_second VALUES ('2011-01-05 15:34:00', 'error', 1);
INSERT INTO data_in_second VALUES ('2011-01-05 15:34:01', 'success', 20);
INSERT INTO data_in_second VALUES ('2011-01-05 15:34:01', 'error', 2);

INSERT INTO data_in_second SELECT time, 'all', SUM(count) FROM data_in_second GROUP BY time;





insert into user_book (isbn, user) select isbn, 'mini9221@naver.com' from user_book where user ='wangdoo@mkinternet.com';


insert into user_book (isbn, email, grade, stand, state, memo) select isbn, 'lhj015@mkinternet.com' as email, grade, stand, state, memo from user_book_bak140102 where user = 'lhj015@mkinternet.com' group by isbn;