如果我有两个结构相同的表,如何将一组行从一个表移动到另一个表?
行集将从选择查询中确定。
例如:
customer table
person_id | person_name | person_email
123 tom [email protected] /cdn-cgi/l/email-protection
persons table
person_id | person_name | person_email
一个样本选择是:
select * from customer_table where person_name = 'tom';
我想将行从客户表移动到人员表
理想情况下,从原始表中删除数据,但这不会破坏交易。
一个简单的插入选择 http://dev.mysql.com/doc/refman/5.0/en/insert-select.html陈述:
INSERT INTO persons_table SELECT * FROM customer_table WHERE person_name = 'tom';
DELETE FROM customer_table WHERE person_name = 'tom';
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)