title: LEFT JOIN not working as it should
body: <p>I'm using LEFT JOIN to only retrieve the latest db entry of a visitor based on the visitors IP for my applications. Somehow it doesnt work correctly. Whenever I use 'AND m1.application_id = '7'' it gets all the connections for the application with 7 as ID. Whenever I try to get the connections for the application with 8 as ID, there is no result while there are connections stored in the database. Am I doing something wrong?</p>
  
  <pre><code>SELECT m1.* FROM `tumblr_tracker` m1
  LEFT JOIN `tumblr_tracker` m2
  ON (m1.ip_address = m2.ip_address AND m1.visit_id &lt; m2.visit_id)
  WHERE m2.visit_id IS NULL AND m1.application_id = '8'
  ORDER BY m1.visit_id
  DESC LIMIT 20
  </code></pre>
  
  <h2><strong>Edited</strong></h2>
  
  <p>What I'm trying to do is as following: I'm storing every Tumblr visit in my database. The data I store is as following: visit_id, ip_address, postal_code, city, region, country, timestamp. So when someone visits my Tumblr, a new entry is being stored in my database. I'd like to show these visits in my adminpanel based on the latest visit timestamp (which is gonna be in the highest visit_id entry for the users ip_address), but I do not want to show the duplicate entries.</p>
  
  <p>So basically: user with ip address: 88.88.88.88 visits my page 5 times, there will be 5 entries in my database with that ip_address. I only want to see all the data of the latest entry.</p>
  
  <p>My db table is called '<strong>tumblr_tracker</strong>'. I have the followings columns:
  - visit_id (AUTO INCREMENT)
  - application_id 
  - ip_address
  - postal_code
  - city
  - region
  - country
  - network
  - timestamp</p>
  
  <p><strong>This is my current code:</strong></p>
  
  <pre><code>$show_tumblr_connections = array(); 
  $get_tumblr_connections = mysqli_query($mysqli,"SELECT m1.* FROM `tumblr_tracker` m1 LEFT JOIN `tumblr_tracker` m2 ON (m1.ip_address = m2.ip_address AND m1.visit_id &lt; m2.visit_id) WHERE m1.application_id = '".$db_application_id."' AND m2.visit_id IS NULL ORDER BY m1.visit_id DESC LIMIT 20") OR die (mysqli_error($mysqli));
  while($row = mysqli_fetch_array($get_tumblr_connections)){
      $tumblr_connections_array = array( 'ip_address' =&gt; $row['ip_address'],
      'postal_code' =&gt; $row['postal_code'],
      'city' =&gt; $row['city'],
      'region' =&gt; $row['region'],
      'country' =&gt; $row['country'],
      'network' =&gt; $row['network'],
      'timestamp' =&gt; $row['timestamp']);
      $show_tumblr_connections[] = $tumblr_connections_array;
  }
  </code></pre>