======무식한 방법======
INSERT INTO table1
( column1-1, column1-2, ...)
VALUES
(
(SELECT column2-1 FROM table2 WHERE column2-x = 9999 ),
(SELECT column2-2 FROM table2 WHERE column2-x = 9999 )
); -- 이것은 하나에 대한 것이다. 여러개를 하는 방법도 마땅찮다.
======더 좋은 방법======
INSERT INTO table1 ( column1-1, column1-2, ...)
SELECT colume2-1, column2-2, ...
FROM table2
WHERE colume2-x IN (SELECT column3-y FROM table3 LIMIT A, B)
Ex)
INSERT INTO table1 (no, title, name, address )
SELECT number, title, given_name, home_address
FROM table2
WHERE number IN (SELECT unique_no FROM table3 LIMIT 0, 100);
INSERT INTO table1
( column1-1, column1-2, ...)
VALUES
(
(SELECT column2-1 FROM table2 WHERE column2-x = 9999 ),
(SELECT column2-2 FROM table2 WHERE column2-x = 9999 )
); -- 이것은 하나에 대한 것이다. 여러개를 하는 방법도 마땅찮다.
======더 좋은 방법======
INSERT INTO table1 ( column1-1, column1-2, ...)
SELECT colume2-1, column2-2, ...
FROM table2
WHERE colume2-x IN (SELECT column3-y FROM table3 LIMIT A, B)
Ex)
INSERT INTO table1 (no, title, name, address )
SELECT number, title, given_name, home_address
FROM table2
WHERE number IN (SELECT unique_no FROM table3 LIMIT 0, 100);
댓글
댓글 쓰기