复制行数据并插入同一个表中

时间:2013-08-01 08:24:47

标签: php sql

我正在尝试复制表中的记录,更改MS访问中的ID并且我收到错误

"SQL error: [Microsoft][ODBC Microsoft Access Driver] The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again., SQL state 23000 in SQLExecDirect"

SQL脚本如下

$hh_copy = "insert into hh (rank_id,entry,R_date,fdp_code,village_code,Fname,Sname,gender,age,OI_num,id_num,HH_idnum,Alt_idnum,HH_name,HH_gender,HH_age,T_type,T_cat,hf5,hf18,hf59,hf60,hm5,hm18,hm59,hm60,hhsize,village_name,address,art_num,activate);

SELECT hh.rank_id,hh.entry,hh.R_date,hh.fdp_code,hh.village_code,hh.Fname,hh.Sname,hh.gender,hh.age,hh.OI_num,'" . $new_id ."',hh.HH_idnum,hh.Alt_idnum,hh.HH_name,hh.HH_gender,hh.HH_age,hh.T_type,hh.T_cat,hh.hf5,hh.hf18,hh.hf59,hh.hf60,hh.hm5,hh.hm18,hh.hm59,hh.hm60,hh.hhsize,hh.village_name,hh.address,hh.art_num,hh.activate FROM hh WHERE hh.id_num = '" . $csv_line[0] ."'";

0 个答案:

没有答案
相关问题