title: query by specific value to query
body: <p>Hi i am trying to do a stored procedure in postgresql,
  and I have to fill a table (vol_raleos), from 3 others, these are the tables:</p>
  <pre><code>super
  zona | sitio | manejo
  1    | 1     | 1
  2    | 2     | 2
  
  datos_vol_raleos
  zona | sitio | manejo |vol_prodn
  1    | 1     | 10     | 0
  2    | 2     | 15     | 0
  
  datos_manejos
  manejoVR | manejoSuper
  10       | 1
  15       | 2
  </code></pre>
  <p>table to fill</p>
  <pre><code>vol_raleos
  zona | sitio | manejo |vol_prodn
  1    | 1     | 1      | 0
  2    | 2     | 2      | 0
  </code></pre>
  <p>So, what I do is take the data that is in <code>datos_vol_raleos</code>, verify that it is in <code>super</code>, but first I must convert the <code>manejoVR</code> value according to the table <code>datos_manejos</code></p>
  <pre><code>INSERT INTO vol_raleos
  (zona, sitio, manejo, edad, densidad, vol_prod1, vol_prod2, ..., vol_prod36)
  
  select zona, sitio, manejo, edad, densidad, vol_prod1, vol_prod2, ..., vol_prod36
  from (
  
      select volr.*, sup.zona, sup.sitio, sup.manejo, dm.manejo,
      from datos_vol_raleos volr
      left join super sup on (sup.zona = volr.zona and sup.sitio = volr.sitio and sup.manejo = volr.manejo) selrs
      order by zona, sitio, manejo, edad, densidad
  
  ) sel_min_max;
  </code></pre>
  <p>so here I don't know how to get the <code>manejoSuper</code> value from datos_manejos, to later compare</p>