如何对数据进行分组以便遵循排序?
SELECT tt.id_img,
tt.number_public,
tt.time_post,
tt.id_public
FROM (SELECT
`number_public`,
`id_img`,
`time_post`,
birthday_publics.id_public
FROM birthday_time_post LEFT JOIN birthday_publics
ON birthday_publics.id = birthday_time_post.number_public
WHERE birthday_time_post.time_post IN(
SELECT MIN(time_post)
FROM birthday_time_post
GROUP BY number_public
)
ORDER BY time_post
) tt
按列time_post
排序答案 0 :(得分:0)
这应该足够了
SELECT
b.`number_public`,
b.`id_img`,
b.`time_post`,
birthday_publics.id_public
FROM birthday_time_post b
INNER JOIN (
SELECT MIN(time_post) min_time
FROM birthday_time_post
GROUP BY number_public
) t on t.min_time = b.time_post
LEFT JOIN birthday_publics ON birthday_publics.id =b.number_public
order by b.time_post