title: MySQL INNER JOIN error in WHERE clause
body: <p>I have problem with query in this example:</p>
  
  <pre><code> SELECT pm.name,
         pm.pre_id,
         pm.pgs_id,
         pm.link,
         pm.del,
         pm.maz_kaina,
         pm.int_kaina,
         pm.d1_kaina,
         pm.d2_kaina,
         pm.d3_kaina,
         pm.pvm,
         pm.vnt,
         pm.gamintojas,
         pm.akcija,
         pm.akc_kaina
  FROM   `prekes_main` AS pm
         INNER JOIN (SELECT charak_pre.pr_id
                     FROM   charak_pre
                     WHERE  charak_pre.cha_id = 206
                            AND charak_pre.reiksme = 'Parfumuotas vanduo'
                            AND charak_pre.pr_id = pm.pre_id) AS reikiamos_pre0
                 ON reikiamos_pre0.pr_id = pm.pre_id
  WHERE  pm.pgs_id = '2431'
  ORDER  BY pm.del DESC,
            int_kaina ASC
  LIMIT  0, 18  
  </code></pre>
  
  <p>I have problem in <code>INNER JOIN</code> when I try execute this. This is error which I got:</p>
  
  <pre><code>SQL Error (1054): Unknown column 'pm.pr_id' in WHERE clause.
  </code></pre>
  
  <p>Location where the error occurs is: <code>and charak_pre.pr_id = pm.pr_id</code>. With this I want to select row from charak_pre table witch equals prekes_main row by keys charak_pre.pr_id and prekes_main.pre_id.</p>