Thursday, April 21, 2011

problem in running complex multiple table mysql query

hey guys

i need to show pages'details , now i used this query to fetch from 3 tables

group_concat( )

its working fine but shows array of tags and topics duplicated.

From stackoverflow
  • You're getting extra rows from the join. Add DISTINCT to the GROUP_CONCAT construct:

    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
    
    Mac Taylor : wow how smart ! thanks man your answer did the trick

0 comments:

Post a Comment