select max(RecordTime) from tbl_loan where UserId = 2 Group By LoanId #### select * from tbl_loan where RecordTime = ? ... $db->execute($var);