Home > Database > Mysql Tutorial > mysql 复制记录实现代码

mysql 复制记录实现代码

WBOY
Release: 2016-06-07 18:01:49
Original
1022 people have browsed it

复制记录,采用自查询方式

sql
代码如下:
INSERT INTO `table` ('id','aa','bb','cc') SELECT 'id','aa','bb','cc' FROM `table` (WHERE .....)

Tips:
代码如下:
/**
* 复制新纪录的时候,可能要更新id或者是部分数据(假设id自增加的情况)
*
* text_aa 为固定值 ,可在脚本调用中赋变量值 如($aa)
* 注意'text_aa' 与 `cc` 的区别 ,一个是数据,一个是字段
**/
INSERT INTO `table` (`id`,`aa`,`bb`,`cc` ) SELECT '','aa内容','bb注意cc符号区别',`cc` FROM `table` (WHERE .....)

/**
* CONCAT(`bb`,'附加信息 -Copy')
* 在提取原有数据的基础上,增加附加信息 (windwos 下见过复件 xxxx.xxx 的都明白)
**/
INSERT INTO `table` (`id`,`aa`,`bb`,`cc` ) SELECT '','aa内容',CONCAT(`bb`,'附加信息 -Copy'),`cc` FROM `table` (WHERE .....)
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template