title: SQL Select default value in a query from a table
body: <p>I have a query which I want to have a default value from a table (you could call it a vlookup in excel). My query looks like this:</p>
  
  <pre><code>select stamdata_sd.id_sd AS id_sd, stamdata_sd.Type_sd
  AS Type_sd from stamdata_sd;
  </code></pre>
  
  <p>I want the <code>Type_sd</code> field in the query to be a default value from a table called <code>type_ty</code>. Something like this:</p>
  
  <pre><code>select stamdata_sd.id_sd AS id_sd, stamdata_sd.Type_sd default(selected
  from a table called type_ty, where the pk id_ty is the higest)
  AS Type_sd from stamdata_sd;
  </code></pre>
  
  <p>So, when i make a new record in the query, the field <code>Type_sd</code> is auto filled with the newest instance in the <code>type_ty</code> table.</p>
  
  <p>How am I able to write such a query?</p>