我需要显示页面的详细信息,现在我使用此查询从 3 个表中获取
group_concat( )
它工作正常,但显示重复的标签和主题数组。
最佳答案
您将从连接中获得额外的行。将 DISTINCT 添加到 GROUP_CONCAT 构造中:
SELECT table_stories.*,
table_stories.sid,table_tags.tid,table_topics.topicid,
group_concat(DISTINCT table_tags.tag ) as mytags,
group_concat(DISTINCT table_topics.topicname ) as mytopics
FROM table_stories,table_tags,table_topics
关于php - 运行复杂的多表mysql查询时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2922322/