MySQL

阅读更多
group by限制列,不适用group by查询时间最小的订单

select user_id,req_money,loan_term,`status`,created_at from renrenhua.order_request a
where not exists
(select b.id from renrenhua.order_request b inner join renrenhua.order_request c on b.user_id=c.user_id and b.created_at>c.created_at where a.id=b.id)




not exists (select 1 from (select user_id from payback_plan group by user_id having count(1) > 1) doubleLoan where doubleLoan.user_id = pp.user_id)

你可能感兴趣的:(mysql)