我想从table1向表2传输50行,我该怎么做?
建议代码:
INSERT INTO table2 SELECT * FROM table1
WHERE uid IN ('23','34','345','567','3242','34322','2') DELETE;
答案 0 :(得分:4)
写2条陈述。如果您使用InnoDB,请将它们放在一个事务中:
START TRANSACTION ;
INSERT INTO table2
SELECT *
FROM table1
WHERE uid IN ('23','34','345','567','3242','34322','2') ;
DELETE FROM table1
WHERE uid IN ('23','34','345','567','3242','34322','2') ;
COMMIT ;
答案 1 :(得分:0)
INSERT INTO table1 (col1, col2, col3) SELECT col1, col2, col3 FROM table2 WHERE col4='some value'
答案 2 :(得分:0)
INSERT INTO TABLE2 SELECT * FROM TABLE1 WHERE COL1 = 'A'