試試這個insert into b select A.* from a left Join b On a.id = b.id Where b.id is null
insert into b select * from a where not exists(select 1 from b where b.id=a.id)在b.id上建索引
insert into b select * from a as tmp where not exists(select 1 from b where id=tmp.id)
同意paoluo(一天到晚游泳的鱼)的想法,这个通过左连接的一般比not in与not exists效率高,但是如果想下率更高,可以在gahade(与君共勉) 所有的方式建立索引,两个表的id都建立索引,然后用paoluo(一天到晚游泳的鱼)的:insert into b select A.* from a left Join b On a.id = b.id Where b.id is null
左连接的一般比not in与not exists效率高??
insert into b select a.* from a where a.id not in(select distinct b.id from b)
左连接的一般比not in与not exists效率高??我不同意这种说法,exists 通常比 in / like 更快. 最好用exists 再在ID上建索引
同意free_pop2k() ( )的说法
insert into b select * from a as t where t.num not in(select num from b )
select * from a
where not exists(select 1 from b where b.id=a.id)在b.id上建索引
select * from a as tmp
where not exists(select 1 from b where id=tmp.id)
最好用exists 再在ID上建索引
select * from a as t where t.num not in(select num from b )
对了,感觉你这人脾气不好。.......