title: MYSQL - SELECT AS alias to be used in subquery
body: <p>I want to be able to use one of the items I am selecting further down in my sub query.
  As you can see in this example I have set the "variable" in question as 100 but in reality this is going to be a dynamic number so I will need to be able to access it in the subquery.</p>
  
  <pre><code>INSERT INTO users_friends (userId, friendId) 
  SELECT 77, id as noob
  FROM users WHERE email = 'a@g.com' 
  AND
  NOT EXISTS (SELECT * FROM users_friends
  WHERE userId = 77 and friendId = noob)
  LIMIT 1
  </code></pre>