MySQL中sql复制一条数据并做修改

 一、复制同表数据,不做修改

      INSERT INTO 表名 (字段)SELECT 字段 FROM 表名 WHERE 条件;

二、复制同表数据同时作出修改

      如果要修改其中某一个字段,在查询语句中:x(要改变的值) as 字段名。

举例:
INSERT INTO billruleregister (billnum,action,ruleId,iorder,overrule,tenant_id,isSystem,isAsyn)
SELECT 'st_purblueinvoicegr',action,ruleId,iorder,overrule,tenant_id,isSystem,isAsyn FROM billruleregister WHERE ruleId = 'puCheckPurInvoiceInvoiceOrgRule' and tenant_id = 0 and billnum in ('st_purinvoice');

你可能感兴趣的:(mysql基础,mysql)