dtnmuyoiw680512744 2012-06-22 16:03
浏览 7

从另一张桌子回填表格; 不能有重复

We have two tables on two different MySQL servers. We have a unique key, which is invoice and date.

We need to grab all of the records from a certain time period and put them into another table. The caveat is that there may be records that exist already so we want to exclude those from the records we are back-filling.

What queries, ideas, scripts, etc. would be the most helpful in accomplishing this?

  • 写回答

2条回答 默认 最新

  • doulongsha5478 2012-06-22 16:08
    关注

    If you put a unique key onto a field that will uniquely identify a record (or a combination of fields), you can use INSERT IGNORE INTO as your MySQL statement. This will insert records, but if a key conflict arises (such as when that record already exists), it will simply proceed to the next record.

    You could also use REPLACE INTO, instead of INSERT INTO, which is similar to INSERT IGNORE INTO, but rather than proceeding to the next record, it will overwrite the conflicted row.

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入