gpt4 book ai didi

mysql - 我们可以对 group_concat(distinct somefield) 做一个 DISTINCT 吗?

转载 作者:行者123 更新时间:2023-11-29 06:37:35 28 4
gpt4 key购买 nike

http://sqlfiddle.com/#!2/37dd94/17

如果我执行 SELECT DISTINCT,我得到的结果与只执行 SELECT 的结果相同。

在查询结果中,您将看到两个包含 District“Evora”的事件。应该只出现一个。

有什么线索吗?

最佳答案

下面的查询 (SQL FIDDLE) 怎么样:

SELECT GROUP_CONCAT(APA_T.district), t.name
FROM tbl_activity AS t
JOIN tbl_activity_package AS ap ON t.id = ap.id_activity
JOIN
(
SELECT DISTINCT apa.district AS district,
(
SELECT s1.id_activity_package
FROM tbl_activity_package_address s1
WHERE apa.district = s1.district
ORDER BY s1.id DESC
LIMIT 1
) AS idActivityPackage
FROM
tbl_activity_package_address apa
ORDER BY apa.district
) AS APA_T
ON ap.id = APA_T.idActivityPackage
GROUP BY t.name
ORDER BY APA_T.district;

上述查询将消除多余的FaroEvora

关于mysql - 我们可以对 group_concat(distinct somefield) 做一个 DISTINCT 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23544348/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com