【发布时间】:2021-11-01 17:50:32
【问题描述】:
我有一个查询返回所有者拥有的项目列表:
WITH all_items
AS
(
SELECT owner.id AS owner,
item.title,
item.importance
FROM owner
JOIN item
ON item.owner_id = owner.id)
SELECT owner.id,
group_concat(DISTINCT item.title ORDER BY item.importance SEPARATOR ',')
FROM owner
JOIN all_items
ON all_items.owner = owner.id
我需要将 group_concat 限制为最多 6 个项目。我不能在 all_items 中执行 LIMIT,因为它只返回前 6 项,无论所有者是谁。我该怎么做?
【问题讨论】:
标签: mysql limit group-concat