title: mysql where condition based on left join field
body: <p>I am working on a logic where If the LEFT joint field is null then a condition in Where should not be applied. Can some one give me an idea how can It be done with only query.</p>
  
  <p>I tried using IF CASE but its not helping,</p>
  
  <p>Query:</p>
  
  <pre><code>SELECT *
  FROM tableA ta
  LEFT JOIN tableB tb ON tb.id = ta.id_c
  WHERE ta.sales = 'Closed'
    AND tb.deleted=0
  </code></pre>
  
  <p>When <strong>ta.id_c</strong> is null, the condition in where <strong>AND tb.deleted=0</strong> shouldnt taken in to account.</p>
  
  <p>Why? Because when there is a null value in the linking ID there is no selection of data for the query. Any help? thanks in advance.</p>
  
  <p>Expected result:
  Select columns of the tables.</p>
  
  <p>Actual Table:</p>
  
  <p>tableA:</p>
  
  <pre><code>id_c    sales  
     1    Closed 
     2    Closed 
  </code></pre>
  
  <p>tableB:</p>
  
  <pre><code>   id  deleted 
     1    0 
  </code></pre>
  
  <p>After Query: Current</p>
  
  <pre><code>id_c    sales   id  deleted 
     1    Closed  1   0
  </code></pre>
  
  <p><strong>EXPECTED</strong></p>
  
  <pre><code>id_c    sales   id    deleted 
     1    Closed  1       0
     2    Closed  NULL   NULL
  </code></pre>
  
  <p>Note: I cannot able to edit the LEFT JOIN conditions</p>