title: Pass Value to Subselect
body: <pre><code>        SELECT
              u.*,
              GROUP_CONCAT(DISTINCT f.shot_id SEPARATOR ",") AS ownFavorites,
              GROUP_CONCAT(DISTINCT st.shot_id SEPARATOR ",") AS ownStars,
              GROUP_CONCAT(DISTINCT s.id SEPARATOR ",") AS ownShots,
              ( SELECT AVG(p.count)
                  FROM points p
                  LEFT JOIN shots s ON s.user_id = **U.ID** AND p.shot_id = s.id
                  WHERE date &gt;= DATE_SUB(CURDATE(),INTERVAL 2 DAY)
              ) AS attention,
              ( SELECT SUM(p.count)
                  FROM points p
                  LEFT JOIN shots s ON s.user_id = **U.ID** AND s.id = p.shot_id
              ) AS popularity
          FROM users u
          LEFT OUTER JOIN shots s ON s.user_id = u.id
          LEFT OUTER JOIN favorites f ON f.user_id = u.id
          LEFT OUTER JOIN stars st ON st.user_id = u.id
          WHERE u.username = ?;
  </code></pre>
  
  <p>I got two subselects which use the parameter u.id (marked in the query). If i do the sql like this it will generate somthing like that:</p>
  
  <pre><code>#1054 - Unknown column 'u.id' in 'on clause'
  </code></pre>
  
  <p>Means, the <code>u.id</code> id is NOT defined in the <code>SubSelects</code>. But in the <code>MainSelect</code> I choose from the <code>users</code> table, where <code>u.id</code> exists.</p>
  
  <p>To my question: Is there a way to pass the selected <code>u.id</code> value to the <code>Subselects</code> with common sql?</p>