title: Remove Repeated Values in LEFT JOIN
body: <p>My SQL string is as follows:</p>
  
  <pre><code>SELECT d.*, a.*
  FROM Documents AS d 
  LEFT JOIN [Document_Attachments] AS a
  ON  d.[Doc No Int] = a.[Document Number]
  AND d.[Revision] = a.[Document Revision]
  WHERE (d.[Lock] = 'off' 
  AND d.[Status] &lt;&gt; 'DELETED') 
  OR (d.[Lock] = 'off' 
  AND d.[Status] IS NULL)
  ORDER BY d.[Filename] ASC
  </code></pre>
  
  <p>This retrieves all the information I require, but also shows duplicates of Table "d" if more than one match is found.</p>
  
  <p>I just need any one match to be retrieved so I know a value exists.</p>
  
  <p>E.g.</p>
  
  <p>Table d:</p>
  
  <pre><code>Doc No Int  Rev
  E-0100      0
  E-0200      0
  E-0300      0
  </code></pre>
  
  <p>Table a:</p>
  
  <pre><code>Document Number     Document Revision   Attachment ID
  E-0100              0                   27
  E-0100              0                   28
  E-0200              0                   46
  E-0300              0                   100
  E-0300              0                   101
  </code></pre>
  
  <p>Information retrieved (I've removed most rows for this example):</p>
  
  <pre><code>Doc No Int  Rev  Attachment ID
  E-0100      0    27
  E-0100      0    28
  E-0200      0    46
  E-0300      0    100
  E-0300      0    101
  </code></pre>
  
  <p>What I would like to be retrieved:</p>
  
  <pre><code>Doc No Int  Rev  Attachment ID
  E-0100      0    27
  E-0200      0    46
  E-0300      0    100
  </code></pre>
  
  <p>So it doesn't really matter which of the "Attachment ID" values is retrieved, I just need to fill the column with a value or a <em>NULL</em> if no match found.</p>
  
  <p>I hope that makes sense.</p>
  
  <p>Thank you.</p>