sql 优化 临时表 差集


SELECT DISTINCT(h.UserId) FROM UserHistory h
LEFT JOIN User u ON h.UserId=u.Id
WHERE u.BizStatus=2;


SELECT UserId FROM ( SELECT DISTINCT(h.UserId) FROM UserHistory h ) AS t
LEFT JOIN User u ON t.UserId=d.Id WHERE u.BizStatus=2;

 

posted @ 2022-12-07 14:49  papering  阅读(25)  评论(0编辑  收藏  举报