How can I remove duplicate value?
You can try like 

 $media_query = db_select('node','n')
         -&gt;distinct()-&gt;innerJoin('field_data_field_media_room_type','mtype','mtype.entity_id = n.nid');
        -&gt;fields('n',array('nid'));
        -&gt;fields('mtype',array('field_media_room_type_tid'));
        -&gt;condition('n.type','media_room_page','=');
        -&gt;condition('mtype.field_media_room_type_tid',$media_id,'=');
        $media_res = $media_query-&gt;execute();       
        while($media_fetch = $media_res-&gt;fetchObject()){
         $media_year = '';
            if(isset($media_node-&gt;field_year['und'][0]) &amp;&amp; $media_node-&gt;field_year['und'][0] !=''){
                $media_year = $media_node-&gt;field_year['und'][0]['value'];
            }
          echo'&lt;pre&gt;';print_r($media_year);
        }


or 

you can use Group By for that particular column.