title: how to retrieve value from two table in mysql using foreign Key is null?
body: <p>i have two tables Test1 and Test2</p>
  
  <h2>Test1 have id and Name</h2>
  
  <pre><code>Id Name
  1 rizwan
  2 nadeem
  3 ramiz
  </code></pre>
  
  <p>and second Table Test2 have middle name and foreign key</p>
  
  <pre><code>id MiddleName id_fk
  1 Hashmi       1
  2 Khan         3
  </code></pre>
  
  <p>now i want to select value from both table if value middle name is not present in second table then <strong>Display only name from first name</strong></p>
  
  <p>i have write a query for this</p>
  
  <pre><code>SELECT Test1.tName,Test2.tMidleName 
  from Test1,Test2 
  where Test1.idTest1=Test2.idTest1 
    AND  Test1.tName='nadeem';
  </code></pre>
  
  <hr>
  
  <p><strong>Above is query but if foreign key is null it will not show values</strong></p>
  
  <p>what should i change in the query if foreign key is null? if it's null i want to show only name from first Table</p>