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 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看