title: SQL Select Statement for last entry in a dynamic table
body: <p>I have a form that allows editing to this datatable. When certain fields are edited I need it to automatically make an entry in another database (I have that part figured out). The not must contain what the variable was before editing and what the variable has been edited to (i.e. "The user's email has been changed from something@somewhere.com to somewherer@something.com"). </p>
  
  <p>With the statement below, I am trying to pull information from the previous entry so I will be able to show what that variable has been changed to. The StartDate is Date/Time variable and the only variable available to pull a chronological entry.</p>
  
  <pre><code>SELECT Top 1 *    
  FROM [Table].[dbo].[Users]
  WHERE TRACK_Num = &lt;cfqueryparam value="#form.ID#" cfsqltype="cf_sql_integer"&gt;
  ORDER BY StartDate DESC
  </code></pre>
  
  <p>The main problem with this method is that it will always select the same entry instead of selecting new entries that are made through the form.</p>
  
  <p>Note: I have edited the entry to include more detail. Thank you for the help.</p>