Mysql数据表A,B中查询存在于A表而不存在于B表,使用userId 进行关联;
select a.* from A a left join B b on a.userId = b.userId and b.userId is null;
或者
select a.* from A a where not exists (select 1 from B a where a.userId = b.userId) ;
或者
select a.* from A a where a.userId not in (select userId from B);
如果查询B表时间段内不存在的关联
select a.* from A a left join (select * from B where addTime > 'xxx' and addTime < 'yyy') b on a.userId = b.userId and b.userId is null;