title: SQL: inner join on alias column
body: <p>Previously I have asked to strip text from a field and convert it to an int, this works successfully. But now, I would like to do an INNER JOIN on this new value.</p>
  
  <p>So I have this:</p>
  
  <pre><code>SELECT CONVERT(int, SUBSTRING(accountingTab.id, PATINDEX('%[0-9]%', accountingTab.id), 999)) 
  AS 'memId',  userDetails.title, userDetails.lname 
  FROM accountingTab INNER JOIN
  (SELECT id, title, first, last FROM memDetTab) AS userDetails ON memID = userDetails.id
  </code></pre>
  
  <p>And then I get the Invalid Column Name <code>memID</code> error.</p>
  
  <p>How can I fix this?</p>