with tmp as ( select user_id, date_format(log_time, '%Y-%m-%d') as date from login_tb ) select distinct user_id from login_tb where (user_id, date_format(date_add(log_time, interval 1 day), '%Y-%m-%d')) in (select * from tmp) and (user_id, date_...