title: SQL JOIN gives double results
body: <p><strong>My database and SQL:</strong> </p>
  
  <p><a href="http://sqlfiddle.com/#!9/ebddb/1/0" rel="nofollow noreferrer">http://sqlfiddle.com/#!9/ebddb/1/0</a>
  <hr><strong>Problem:</strong> </p>
  
  <p>It's returning duplicates, with the wrong data in the <code>name</code>-column, when there are less than 7 records in the <code>notchtype</code>-table</p>
  
  <p><hr>
  <strong>My Question:</strong> </p>
  
  <p>Why does it return duplicates and how to prevent it?</p>
  
  <p><hr>
  <strong>Expected result:</strong></p>
  
  <p>This fiddle shows the expected result: <a href="http://sqlfiddle.com/#!9/22660/1" rel="nofollow noreferrer">http://sqlfiddle.com/#!9/22660/1</a></p>
  
  <p><em>In this result the only thing more added than in my actual database and SQL are 2 records in the <code>notchtype</code>-table</em></p>
  
  <p>So the <code>id</code>, <code>notchid</code> and <code>number</code> columns should be unique in the returned rows.</p>
  
  <p>The screenshot in the answer of Piyush Gupta is showing the right expected result. The same query on SQL fiddle and locally on MariaDB version 10.1.9 are returning something different</p>
  
  <p><hr>
  <strong>Notes:</strong> </p>
  
  <ul>
  <li>I found out that when there at least 7 records in the <code>notchtype</code> table, there are suddenly no duplicates anymore and the problem is 'solved'.</li>
  <li>The <code>null</code> values should indeed be <code>null</code>.</li>
  <li>The <code>size</code>-column is actually returning the right values, although the <code>LEFT JOIN</code> is more or less the same</li>
  <li>The ID's in <code>notches.notchdescr</code> 'connects' with the ID's in <code>notchtype.notchtypeid</code> column and is returned as the <code>name</code> column in the fiddle</li>
  <li>The ID's in <code>notches.notchsize</code> 'connects' with the ID's in <code>notchsize.notchsizeid</code> column and is returned as the <code>size</code> column in the fiddle</li>
  </ul>
  
  <p><hr>
  <strong>Not working:</strong></p>
  
  <ul>
  <li><code>INNER JOIN</code>, don't know why</li>
  <li><code>DISTINCT</code>, because the <code>name</code>-columns have different values, so there not exact duplicates</li>
  <li><code>GROUP BY</code>, because it returns all the same values in the <code>name</code>-column</li>
  </ul>
  
  <p><hr>
  <strong>Update on answer/comments from Piyush Gupta</strong></p>
  
  <p>Query executed on MySQL 5.7:</p>
  
  <pre><code>SELECT 
          notches.id,
          notches.notchid,
          notches.number,
          notches.xcoord,
          notches.ycoord,
          notches.mapid,
          notches.location,
          notches.date,
          notches.price,
          notches.invoiced,
          notchsize.size AS notchsize,
          notchtype.name AS notchdescr
  FROM 
      notches 
  LEFT JOIN
      notchtype ON
      notches.notchdescr = notchtype.notchtypeid
  LEFT JOIN
      notchsize ON
      notches.notchsize = notchsize.notchsizeid
  WHERE 
      notches.del = 0 
  AND
      notches.projectid = '2016032411364363055'
  GROUP BY notches.id, notches.notchid, notches.number
  ORDER BY notches.number ASC
  </code></pre>
  
  <p>Result:</p>
  
  <p><a href="https://i.stack.imgur.com/hj5Jg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hj5Jg.png" alt="Result"></a></p>
  
  <p><hr>
  <strong>SOLVED!</strong></p>
  
  <p><code>LEFT JOIN</code> on <code>VARCHAR</code> = <code>BIGINT</code> field causes the strange returned values. See answer and comments of Piyush Gupta</p>