title: Select only If column name is not Null
body: <p>I have two table </p>
  
  <p>Table1 - <code>tblEmployee</code> </p>
  
  <pre><code> EmployeeId      ContactInfoID
     1001            1
     1002            2
  </code></pre>
  
  <p>Table2 - <code>tblContactInfo</code></p>
  
  <pre><code>    ContactInfoID  FirstName MiddleName LastName
       1                Ram     Prasad     Dhakal
       2                Hari    Null        Rai
  </code></pre>
  
  <p>Here I want to Select <code>FirstName, MiddleName, LastName</code> only if that is not <code>Null</code>.If I select <code>EmployeeID=1001</code> then <code>FirstName, MiddleName, LastName</code> should be selected and if <code>EmployeeID = 1002</code> only <code>FirstName</code> and <code>LastName</code> should be selected.  </p>
  
  <p>I tried this code </p>
  
  <pre><code>SELECT FirstName, MiddleName, LastName
  FROM `tblemployee` AS E INNER JOIN 
  `tblcontactinfo` AS C 
  ON E.ContactInfoID= C.ContactInfoID
  WHERE E.EmployeeID= 1001
  AND MiddleName is null;
  </code></pre>
  
  <p>But I am not getting required result. Which query should I use?</p>