1. tb_order表和 tb_expend 联查,搜索 userid。然后用户表 id in( 搜索语句) 获取全部用户信息 。
select * from tb_user where id in ( select o.userid from tb_order as o,tb_epend as e where o.userid = e.userid and o.lunch = 1 and e.expens != 20 and e.orderdata >= '2020-11-1' and e.orderdate <= '2020-11-7')
第二个换下条件