title: SQL Server: how to use alias in update statement?
body: <p>I'm wondering about the following query : </p>
  
  <pre><code>   UPDATE statisticsTable
     SET Value = (select count(*) 
                  FROM OtherTable o
                  WHERE o.UserId = UserId ) &lt;-- this is the part that concerns me
     WHERE id in (1,2,3) 
  </code></pre>
  
  <p>How does SQL Server know that the second "UserId" field comes from <code>statisticsTable</code> and not from <code>OtherTable</code> ?
  Why can't I give an alias to statisticstable like 'stat' to clarify where I want to get that UserId ? Or is there a way?</p>