title: MYSQL: Error 1054 - Unknown Column
body: <p>Before we start, I apologize for my MYSQL novice status.  I'm trying to self-teach and struggling a bit with basic the basic structure.</p>
  
  <p>Background on my question: Consider a company that issues bills once a quarter... and roughly two months after the end of the last quarter.  I have a table (Quarter_Identify) that has several columns:</p>
  
  <ul>
  <li>Quarter_Start  EX: 01-01-2010 </li>
  <li>Quarter_End    EX: 03-31-2010</li>
  <li>Quarter_Ident  EX: 1000  &lt;--- iterating number for each quarter (next
  quarter will be 1001)</li>
  <li>Date_Billed    This is the field I'm trying to populate from another table</li>
  </ul>
  
  <p>The other table (Billing_List_1) contains:</p>
  
  <ul>
  <li>Date_Billed    EX: 05-23-2010   </li>
  <li>Lots of other nonsense related to the customers</li>
  </ul>
  
  <p>We take all the orders during the quarter, and bill about 60 days after it ends.  So, in the example above, the 5-23-2010 billing would be related to the Jan - Mar quarter (we bill really late).  I would like to take this date and populate it back as the Date_Billed associated with Quart_Ident "1000".</p>
  
  <p>I'm fairly close and from my research I think I'm running into the issue that my "Where" clause includes a reference to the as-yet not created table "Skyline".  The "skyline" table gets everything together, but is essentially off by a month (I gave up trying to figure out the DateDiff function).  So, I use the bottom piece to offset the result by one and get the right answer... except that it tells me I have an unknown column in my where clause (error 1054) the issue.</p>
  
  <pre><code>Select * from
      (select Billing_List_1.date_billed, quarter_identify.quarter_start,
        quarter_identify.quarter_end, quarter_identify.quarter_ident from Billing_List_1
      join quarter_identify
      on Billing_List_1.date_billed &gt; quarter_identify.quarter_start 
        and Billing_list_1.date_billed &lt; quarter_identify.quarter_end)
  as SKYLINETABLE;
  
  update quarter_identify A
      set A.date_Billed = SKYLINETABLE.date_Billed 
      where A.quarter_ident = SKYLINETABLE.quarter_ident - 1
  </code></pre>
  
  <p>Any thoughts would be much appreciated.  Have a great evening all.</p>
  
  <hr>
  
  <p>Solution per TEEZ:  Thanks again for the great help.</p>
  
  <pre><code>update quarter_identify A Left join 
      (Select * from
          (select     Billing_List_1.date_billed, 
                      quarter_identify.quarter_start, 
                      quarter_identify.quarter_end, 
                      quarter_identify.quarter_ident from billing_list_1
          join quarter_identify
          on Billing_list_1.date_billed &gt; quarter_identify.quarter_start 
          and Billing_list_1.date_billed &lt; quarter_identify.quarter_end) 
      as T)
      as SKYLINETABLE on 1
      set A.date_billed = SKYLINETABLE.date_billed 
      where A.quarter_ident = SKYLINETABLE.quarter_ident - 1
  </code></pre>