title: mysql select only unique values which has not been assigned to any other
body: <p>My database looks something like this</p>
  
  <pre><code>id document_id resource_id language filename
  1   11          120         English     abc
  2   13          120         German      ghy
  3   56          120         Norway      hyu
  4   56          156         Norway      hyu
  5   89          134         Hindi       uiy
  6   90          120         English     qwer
  </code></pre>
  
  <p>In this I want to get all the values for resource_id 120. So I can make a query like</p>
  
  <pre><code>SELECT * FROM `table` WHERE resource_id = 120
  </code></pre>
  
  <p>But as you can see in the table there is one column for document_id and if you check closer then you can see that the document_id 56 is assigned for two resources. One for 120 and another for 156. So can some one tell me how to check this in mysql sub query.</p>
  
  <p>So my output will be it will show all the data only for resource_id 120. If any other resource is assigned with any document_id which has been shared with resource_id 120 it will be not shown. So only unique data for only 120 resource_id should be shown.</p>
  
  <p>So I have made my query so far like </p>
  
  <pre><code>SELECT * 
    FROM `table` 
   WHERE resource_id = 120 
     AND `document_id` IN("SELECT `id` FROM `table` WHERE  `resource_id` &lt;&gt; 120 ")
  </code></pre>
  
  <p>So can someone tell me how to get the value? Any help and suggestions will be really appreciable. Thanks</p>