I\'ve got two tables (members and activities) and I\'m trying to query the members with the latest activity for each member. I\'ve got it working with two queries (one to get t
SELECT
members.id ,
members.name,
activities.code AS activity_code,
activities.timestamp AS activity_timestamp,
activities.description AS activity_description
FROM
members
LEFT JOIN activities
ON members.id = activities.member_id
LEFT JOIN
(
SELECT
activities.member_id
MAX(activities.id) AS id
FROM activities
GROUP BY
activities.member_id
) AS t1
ON activities.id = t1.id
WHERE
t1.id IS NOT NULL