insert into tongji
select * from tmptab
where cardnum, xfdate, xftime
not in ( select cardnum, xfdate, xftime from tongji ) ;
...全文
1644打赏收藏
我这句sql语句哪里错了?
把统计数据load入了临时表tmptab,然后选择不重复的记录插入表tongji insert into tongji select * from tmptab wherecardnum, xfdate, xftime not in ( select cardnum, xfdate, xftime from tongji ) ;
最后的条件错了,修改如下:
insert into tongji select tmptab.* from tmptab left outer join tongji on tmptab.cardnum=tongji.cardnum and tmptab.xfdate=tmptab.xfdate and tmptab.xftime=tongji.xftime where tongji.cardnum is null
insert into tongji select tmptab.* from tmptab left outer join tongji on tmptab.cardnum=tongji.cardnum and tmptab.xfdate=tmptab.xfdate and tmptab.xftime=tongji.xftime where tongji.cardnum is not null
大致是这样,试试吧.