title: MySQL sort table by 2 columns of 2 tables
body: <p>I thought this would be easy, but I don't find a solution:</p>
  
  <p>I have a very large table with items that have a "name" column. </p>
  
  <p>I have a second table with corresponding "localized name" for some of the items of table 1.</p>
  
  <p>I now want table 1 ordered by "localized name" from table 2, but if no localized name exists ordered by "name" from table 1.</p>
  
  <p>Example:</p>
  
  <p>Table 1</p>
  
  <pre><code>id name
  1  USA
  2  Italy
  3  Germany
  4  Australia
  </code></pre>
  
  <p>Table 2</p>
  
  <pre><code>id loc_name    t1_id
  1  Italia      2
  2  Deutschland 3
  </code></pre>
  
  <p>Result</p>
  
  <pre><code>4 Australia
  3 Deutschland
  2 Italia
  1 USA
  </code></pre>