title: MySQL left outer join query
body: <p>I have two tables, </p>
  
  <p>first table structure (data) :</p>
  
  <pre><code>-id
  -name
  -title
  -mail
  -source_id
  </code></pre>
  
  <p>and second table ( mail ) :</p>
  
  <pre><code>-id
  -record_id
  -mail
  -date
  </code></pre>
  
  <p>there may be some duplicate records in data table and some records with empty mail field.
  im sending emails to these clients and i want to save whos email has been sent with time in mail table.
  and i want to exclude records which their emails has been already sent</p>
  
  <p>i use this query : </p>
  
  <pre><code>SELECT * FROM `data`
  LEFT OUTER JOIN `mail`
  ON `data`.`source_id` != `mail`.`record_id`
  WHERE `data`.`mail` != ''
  ORDER BY `data`.`id` ASC LIMIT 1
  </code></pre>
  
  <p>also i tried :</p>
  
  <pre><code>SELECT * FROM `data`
  LEFT OUTER JOIN `mail`
  USING(`mail`)
  WHERE `data`.`mail` != ''
  ORDER BY `data`.`id` ASC LIMIT 1
  </code></pre>
  
  <p>but it still shows duplicate records and dont exclude records from mail table</p>
  
  <p>any ideas ? or better solution ? btw i cant alter first table and add a new field for checking sent emails</p>
  
  <p>thanks in advance</p>