mysql copies the record implementation code
- 2020-05-09 19:25:46
- OfStack
sql
Tips:
INSERT INTO `table` ('id','aa','bb','cc') SELECT 'id','aa','bb','cc' FROM `table` (WHERE .....)
Tips:
/**
* When copying a new record , It might be updated id Or partial data ( Assuming that id Student: self increasing )
*
* text_aa For a fixed value , You can assign variable values in script calls Such as ($aa)
* Pay attention to 'text_aa' with `cc` The difference between ,1 Is the data ,1 Is the field
**/
INSERT INTO `table` (`id`,`aa`,`bb`,`cc` ) SELECT '','aa content ','bb Pay attention to cc Symbolic distinction ',`cc` FROM `table` (WHERE .....)
/**
* CONCAT(`bb`,' Additional information -Copy')
* On the basis of extracting the original data , Add additional information (windwos I saw the copy below xxxx.xxx Of all understand )
**/
INSERT INTO `table` (`id`,`aa`,`bb`,`cc` ) SELECT '','aa content ',CONCAT(`bb`,' Additional information -Copy'),`cc` FROM `table` (WHERE .....)