gpt4 book ai didi

mysql - 插入到从删除中选择

转载 作者:行者123 更新时间:2023-11-29 04:53:05 26 4
gpt4 key购买 nike

我想将50行从table1转移到table 2,我应该怎么做?

建议代码:

    INSERT INTO table2 SELECT * FROM table1 
WHERE uid IN ('23','34','345','567','3242','34322','2') DELETE;

最佳答案

写 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 ;

关于mysql - 插入到从删除中选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9512089/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com