表1和表2

u1zaf5dj 2010-01-13 04:13:28
请教:有2个表,表1和表2.想每天把表1的记录放到表2里,表2里已经有的记录即以前放过的记录就不再放了。就是说每天要把表1里新出现的表2里没有的记录进入表2,怎样实现呢??(不好意思,小弟表达能力有限)
...全文
79 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
varick_zhong 2010-01-13
  • 打赏
  • 举报
回复
楼主如果是不管表1中修改和删除和记录的话是否是可以这样,在表1表2中都加一个时间,保存记录保存的时间,那么第二天表2从表1导数据的话就直接日期等于第二天就行了,要不然就insert into 表2
select * from 表1
where id not in (select Id from 表2 )这个行了
dinoalex 2010-01-13
  • 打赏
  • 举报
回复
注意表2的id是否自增字段
kfcoffe 2010-01-13
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 chao3428 的回复:]
insert into 表2
select * from 表1
where id not in (select Id from 表2 )
[/Quote]

这个方法很好,对sql不熟悉,学习了
chao3428 2010-01-13
  • 打赏
  • 举报
回复
insert into 表2
select * from 表1
where id not in (select Id from 表2 )
chao3428 2010-01-13
  • 打赏
  • 举报
回复
insert into 表2
select * from 表1
where id not (select Id from 表2 )
chhrsas 2010-01-13
  • 打赏
  • 举报
回复
insert into 表2
select * from 表1
where not exists(select * from 表2 where 表1.关键字= 表2.关键字)
u1zaf5dj 2010-01-13
  • 打赏
  • 举报
回复
能详细点吗?谢谢
kfcoffe 2010-01-13
  • 打赏
  • 举报
回复
把2个表都查询出来,然后把表一里面的每个记录和表二中的比较,如果没有就插入表二。
brightyang 2010-01-13
  • 打赏
  • 举报
回复
select into

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧