我有一个选择组和组发布的查询。在postss表中有一个时间戳collumn和一个group_id。我需要在发布表中选择与组ID相关联的最大时间戳。
这是我的查询
$query = "
SELECT groups.group_name, groups.group_info, groups.group_tags, postings.timestamp
FROM groups
LEFT JOIN postings ON groups.group_id = postings.group_id
GROUP BY groups.group_id
ORDER BY `postings`.`timestamp` DESC
";
答案 0 :(得分:0)
$query = "
SELECT groups.group_name, groups.group_info, groups.group_tags, max(postings.timestamp)
FROM groups
LEFT JOIN postings ON groups.group_id = postings.group_id
GROUP BY groups.group_id
ORDER BY `postings`.`timestamp` DESC
";