title: Search Filter Join with 3 tables based on particular condition
body: <p>I have 3 tables namely t1,t2,t3 .</p>
  
  <p><strong>Table : t1</strong><br>
  Description : Store Uploaded Files</p>
  
  <pre><code>id | filename | display_filename | uploaded_path
  </code></pre>
  
  <p><strong>Table : t2</strong><br>
  Description : Store Replaced Files
  Replaced Files means  i have added an option for replacing uploaded files. So the files from t1 will moved to t2</p>
  
  <pre><code>id|fileid | filename | display_filename | uploaded_path
  </code></pre>
  
  <p><strong>Table : t3</strong></p>
  
  <p>Description : Log Details of visited Files</p>
  
  <pre><code>id|fileid|userid|action|access_time|ip_Address|is_backup(0 /1)
  </code></pre>
  
  <p><code>is_backup</code> column is used for knowing whether the file visited  is older or not</p>
  
  <p>I have added a view for listing log details with filter by <code>display_file_name</code></p>
  
  <p>My problem is </p>
  
  <p>if <code>is_backup</code> value is <code>0</code> then i wanted to get <code>display_filename</code> from <strong>t1</strong> otherwise <strong>t2</strong></p>
  
  <p>How can i write query for retrieving the filter data ?</p>
  
  <pre><code>SELECT t3.* FROM t3  
  LEFT JOIN t1  
  ON t1.id = t3.fileid 
  LEFT JOIN t2 
  ON  t2.fileid  = t3.fileid
  WHERE t1.display_filename LIKE '%abc%';
  </code></pre>
  
  <p>The above query will only check in table <strong>t1</strong>
  I want to check in <strong>t2</strong> based on <code>is_backup</code> value</p>