Is there a more efficient way of doing the following?
select * from foo as a where a.id = (select max(id) from foo where uid = a.uid group by uid)
Returning the last row of each GROUP BY in MySQL with WHERE clause:
GROUP BY
WHERE
SELECT * FROM foo WHERE id IN ( SELECT Max(id) FROM foo WHERE value='XYZ' GROUP BY u_id ) LIMIT 0,30