当前位置:主页>仓库管理软件> 列表

怎样删除两个表中不同的数据

仓库管理软件版1楼: 假如有两个表第一个表存有 0,1,2,3,4,5,6,7,8,9,10,11,第二个表存有2.3,5,7,9,11,20,现在要删除第一个表中不同于第二个表中的数据,该怎么删,我用了delete b1 from b1,b2 where b1.num<>b2.num,num为表的列名,可一执行表1中的数据全删除了,用where b1.num=b2.num倒是表1中可表2中想同的数据删掉了,怎么回事?难道有错?应该怎么定才正确?请各位大师急救!!!多谢!!!!

2楼: delete b1 where num not in(select num from b2); 如在线进销存

3楼: 多谢

4楼: 如还要要把第一个表中没有的,第二个表中有的数据如,20再插入第一个表中该怎么写?
insert b1 select *from b2 where num not in (select num not in b2),一执行倒是能执行,但没有插进去,该怎么写?多谢!!1

5楼: 你直接把第1个表删除,把第2个表复制为第1个表吧[:D][:D][:D][:D][:D]

6楼: insert b1 select *from b2 where num not in (select num not in b2)是不是应该这样写:
insert b1 select * from b2 where num not in (select num form b1)

仓库管理软件版7楼: 你写错了,应该这样写
insert b1 select *from b2 where num not in (select num not in b1)

8楼: 还是最后一楼的wangwb说得对,加分!