title: MySQL VIEW with IF statement
body: <p>i have two tables in mMySQL:</p>
  
  <pre><code> - news (news_id, news_titel, news_file_id)
   - files (file_id, file_path, file_name)
  </code></pre>
  
  <p>I would like to create MySQL VIEW with these columns:</p>
  
  <pre><code>- news_view (news_id, news_title, news_file_id, news_file_path)
  </code></pre>
  
  <p>But, if <code>news_file_id &gt; 0</code> then, i get the path of file (<code>file_path + file_name</code>) else <code>news_file_path</code> should be <code>0</code></p>
  
  <p>How can i do this VIEW?</p>
  
  <p>EDIT</p>
  
  <p>but what if i want to add two more tables :</p>
  
  <pre><code>categories (category_id, category_name)
  users(user_id, user_name)
  </code></pre>
  
  <p>and table <code>news</code> changed to</p>
  
  <pre><code>news (news_id, news_title, news_file_id, news_author_id, news_category_id)
  </code></pre>
  
  <p>and view should show only posts with specifed <code>news_author_id</code>, <code>news_category_id</code>, but <code>news_file_path</code> like in the original question?</p>
  
  <p>Thanks,
  Paul.</p>