title: Joins in MySQL on NULL values
body: <p>I have to do a query in MySQL. I have to find all airports, which can be reached within maximum 4 stepovers.
  This is my query:</p>
  
  <pre><code>SELECT fp0.from AS start, fp1.from AS stop1, 
    fp2.from AS stop2, fp3.from AS stop3, 
    fp4.from AS stop4,fp4.to AS end 
  FROM flightplan AS fp0 
  LEFT JOIN flightplan AS fp1 ON( fp0.to=fp1.from ) 
  LEFT JOIN flightplan AS fp2 ON( fp1.to=fp2.from ) 
  LEFT JOIN flightplan AS fp3 ON( fp2.to=fp3.from ) 
  LEFT JOIN flightplan AS fp4 ON( fp3.to=fp4.from ) 
  WHERE fp0.from=6626
  </code></pre>
  
  <p>The result:</p>
  
  <pre><code>6626,"9895","4887","12836","10304","9915"   
  6626,"9895","4887","12836","10304","4595"    
  6626,"9895","4887","12836","10304","2685"    
  6626,"9895","4887","12836","164","12081"    
  6626,"9895","4887","12836","1652","8686"    
  6626,"9895","4887","12836","1298","6682"    
  6626,"9895","4887","12836","5965","10953"    
  6626,"9895","4887","12836","5965","7212"    
  6626,"9895","13070",**NULL**,NULL,NULL    
  6626,"9895","13070","4859","12820","6908"    
  6626,"9895",**NULL**,NULL,NULL,NULL
  </code></pre>
  
  <p>The result is wrong at 2 points ( I marked them with stars ). The problem is, that I check, if the "to" airport a1 equals the "from" airport a2. But if the "to" airport is NULL, I get the wrong result.</p>
  
  <p>Can somebody help me with my problem?
  Thank you </p>
  
  <p>PS: I am not allowed to do this recursively.</p>