Home > Backend Development > PHP Tutorial > mysql复制某一条记要

mysql复制某一条记要

WBOY
Release: 2016-06-13 13:13:27
Original
1257 people have browsed it

mysql复制某一条记录
$sql="insert into table1 (*) select * from table1 where id=$id";


上面是错误的

1.ID自动增加
2.复制所有字段内容

请问要怎么完善。

------解决方案--------------------
你需要开列除 id 以外的字段名
------解决方案--------------------
复制的字段要对应你的inser into tablename1(a,b) select a,b from tablename
------解决方案--------------------
如果不想手工开列字段,可以使用程序来做
由于有主键,不开列是不行的
何况 mysql 一直建议:为了提高效率,请开列所需字段,而不是简单的 * 一下
------解决方案--------------------
就跟平常写入一样,必须字段值相对应

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