我在mysql查询中使用GROUP_CONCAT
,但查询给了我意想不到的未知结果。这是查询:
SELECT GROUP_CONCAT( DISTINCT (categoryid) )
FROM jos_community_groups
WHERE team_classification
IN (
SELECT id
FROM jos_league_classification
ORDER BY winning_criteria ASC
)
AND show_in_contact =1
AND team_state = 'Georgia'
AND categoryid
IN (
SELECT sportstypeid
FROM jos_gsa_tournament
WHERE directorid =305
)
ORDER BY categoryid, team_agegroup, team_classification
结果看起来像这样
GROUP_CONCAT( DISTINCT ( categoryid ) ) // column
[BLOB - 10B] // result
我想要逗号分隔的categoryid字符串,但我不明白为什么查询会提供此类型的结果以及查询中缺少的内容。
答案 0 :(得分:2)
问题仍不明确,但我想这可以解决您的问题。 像这样放一个cast aroung group_concat:
cast(group_concat(DISTINCT(categoryid))为char)