本文介绍了复制 MySQL 记录的最快方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简单的问题,我有一个关于 WHERE 的查询,我需要通过将 1 字段更改为不同的值来复制它?还有一个我无法复制的唯一增量 ID 字段.

Simple question, i have a query with some WHERE and i need to duplicate it with a change to 1 field to a different value? There is a unique increment ID field as well which I cannot duplicate.

推荐答案

按照这些思路应该可以工作.这将使您能够访问要复制的行,您只需选择要为新行插入的值,替换其中之一即可.

Something along these lines should work. This will give you access to the row that you want to duplicate, and you just select the values to insert for the new row, replacing one of them.

INSERT tblData
( -- Lets pretend Column1 is your key
   Column2
   , Column3
)
SELECT
   Column2
   , Column3 + 5 /*Replace this with whatever value is you want*/
FROM tblData
WHERE Column1 = @Id

这篇关于复制 MySQL 记录的最快方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-27 21:09