title: mysql GROUP_CONCAT DISTINCT multiple columns
body: <p>I have a tag field for a blog posts. tags have unique id but their displayName might be duplicated. What I want is a query that selects posts and in <code>all_tags</code> field we get couples of (id,displayName) is this way:</p>
  
  <pre><code>id1,name1;id2,name2;id3,name3
  </code></pre>
  
  <p>My query looks like:</p>
  
  <pre><code>select ....
  CONCAT_WS(';', DISTINCT (CONCAT_WS(',',tags.id,tags.displayName))) AS all_tags
  Join ...post content ...
  Join ...post_tags ...
  Join ...tags ...
  ORDER BY posts.id
  </code></pre>
  
  <p>This line causes problem:</p>
  
  <pre><code>CONCAT_WS(';', DISTINCT (CONCAT_WS(',',tags.id,tags.displayName))) AS all_tags
  </code></pre>
  
  <p>How should I modify it?</p>
  
  <p>Some people use an inner <code>(SELECT .. FROM)</code> but as I have heard, it is so inefficien</p>
  
  <hr>
  
  <pre><code>SELECT `posts`.*,`categories`.*,`creators`.*,`editors`.*
  CONCAT_WS(';', DISTINCT GROUP_CONCAT(CONCAT_WS(',',tags.id,tags.displayName))) AS all_ids
  FROM (`posts`) 
  LEFT JOIN `languages` ON `posts`.`language_id`=`languages`.`id` 
  LEFT JOIN `users` as creators ON `posts`.`creatorUser_id`=`creators`.`id` 
  LEFT JOIN `users` as editors ON `posts`.`lastEditorUser_id`=`editors`.`id` 
  LEFT JOIN `userProfiles` as editors_profile ON `editors`.`profile_id`=`editors_profile`.`id` 
  LEFT JOIN `categories` ON `posts`.`category_id`=`categories`.`id` 
  LEFT JOIN `postTags` ON `postTags`.`post_id`=`posts`.`id` 
  LEFT JOIN `tags` ON `postTags`.`tag_id`=`tags`.`id` 
  LEFT JOIN `postTags` as `nodetag_checks` ON `nodetag_checks`.`post_id`=`posts`.`id` 
  LEFT JOIN `tags` as `tag_checks` ON `nodetag_checks`.`tag_id`=`tag_checks`.`id` 
  WHERE ( 9 IN(`tag_checks`.`id`,`tag_checks`.`cached_parents`) OR 10 IN(`tag_checks`.`id`,`tag_checks`.`cached_parents`) OR 11 IN(`tag_checks`.`id`,`tag_checks`.`cached_parents`)) 
  GROUP BY `posts`.`id` ORDER BY `posts`.`created` desc LIMIT 0, 20  
  </code></pre>