Getting distinct values only using relations

In my database I have 5 tables:


tag (tag_id,name,…)

collection (coll_id,name,…)

collections_tags (id,coll_id,tag_id)

game_tag (id,game_id,tag_id)

Here are the relations in Collection model:

'collections_tags'=>array(self::HAS_MANY,'CollectionsTags',  'coll_id'),

                    'tags'=>array(self::HAS_MANY, 'Tag',  array('tag_id'=>'tag_id'),'through'=>'collections_tags'),

                    'game_tags'=>array(self::HAS_MANY, 'GameTags',array('tag_id'=>'tag_id'), 'through'=>'tags'),

                    'top_coll_games'=>array(self::HAS_MANY, 'Game',



                        'order'=>'views DESC',



I get the games for collection with:


When there is a game that matches 2 or more tags, the query returns: game1,game1,game2 and the $collection->top_coll_games has two values because the game1.

How can I fetch from db without repetition with relations?

thank you.

You can try to add the select attribute in the relations like in this post.