SELECT *
FROM student as std LEFT JOIN
(SELECT * FROM billing WHERE `paid` < '4' ) AS bill
ON bill.reg_id = std.reg_id
GROUP BY bill.reg_id
ORDER BY bill.id
Here student table is main table and its primary key is foreign key in billing table. There are multiple records in billing table with student reg_id .
I want latest billing record with limit 1 and no limit on student table.