我的mysql查询如:
SELECT GROUP_CONCAT(scorecard_id ORDER BY scorecard_id DESC) as scorecard_id
FROM scorecard
WHERE partner_id = 121 AND client_id = 15
它返回我的数据:
65,64,63,62,61,60,39,38,37,36,35,34,33,32,31,30,29...
我想在 group_concat 中添加限制,以便它返回前2个值,即:
65,64
答案 0 :(得分:0)
也许用子查询包围:
SELECT
GROUP_CONCAT(t.scorecard_id) AS scorecardId
FROM
(
SELECT
scorecard_id
FROM scorecard
WHERE
partner_id = 121
AND client_id = 15
ORDER BY scorecard_id DESC
LIMIT 2
) AS t;