用Group by分组后,取每组的前3条记录,怎么取?
- 使用子查询进行查询
SELECT
*
FROM
home_content a
WHERE
(
SELECT
count(id)
FROM
home_content
WHERE
class_link = a.class_link
AND id > a.id
) <= 2
只言片语任我说,提笔句句无需忖。落笔不知寄何人,唯有邀友共斟酌。
SELECT
*
FROM
home_content a
WHERE
(
SELECT
count(id)
FROM
home_content
WHERE
class_link = a.class_link
AND id > a.id
) <= 2