doumen5491 2013-08-24 14:12
浏览 42
已采纳

尝试将条目从备份表还原到主表

So some background. I have a pair of tables that store 'Application Information' for prospective employees.

The main table is displayed with PHP/SQL and there is a link to 'Delete' an application from the table.

INSERT INTO ResultsOLD SELECT * FROM Results WHERE Results.id = '$IDin'

DELETE FROM Results WHERE Results.id = '$IDin' AND Timestamp = '$INts'

The above entries copy the data to the backup table (old app storage) and deletes the entry from the Main table.

I am now trying to write a recovery page, so that an entry can be returned from the Backup table, back into the Main table (No deletion from Backup Table). I have the following SQL query:

INSERT INTO Results SELECT * FROM ResultsOLD WHERE ResultsOLD.id = '$IDin'

But when I try to run this query off of the new page, it gives an error. I have tried researching the error but I do not understand what it is saying (I am somewhat new to SQL).

This is the error I get:

An explicit value for the identity column in table 'Results' can only be specified when a column list is used and IDENTITY_INSERT is ON.

Is this because I am using the ID in the WHERE, which is the Primary Key? Also when I reinsert the data from the ResultsOLD table, I want to assign a new ID (Primary Key) to the entry but keep everything else intact. The ID is auto-increment, but I think because I am using the ID as the WHERE, it might be trying to insert that also?

  • 写回答

1条回答 默认 最新

  • dongzhan1383 2013-08-24 14:18
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题