title: UPDATE  Syntax with ORDER BY, LIMIT and Multiple Tables
body: <p>Learning SQL, sorry if this is rudimentary. Trying to figure out a working <code>UPDATE</code> solution for the following pseudoish-code:</p>
  
  <pre><code>UPDATE tableA 
  SET tableA.col1 = '$var'
  WHERE tableA.user_id = tableB.id
  AND tableB.username = '$varName'
  ORDER BY tableA.datetime DESC LIMIT 1
  </code></pre>
  
  <p>The above is more like <code>SELECT</code> syntax, but am basically trying to update a single column value in the <strong>latest row</strong> of tableA, where a username found in tableB.username (represented by $varName) is linked to its ID number in tableB.id, which exists as the id in tableA.user_id.</p>
  
  <p>Hopefully, that makes sense. I'm guessing some kind of <code>JOIN</code> is necessary, but subqueries seem troublesome for <code>UPDATE</code>. I understand <code>ORDER BY</code> and <code>LIMIT</code> are off limits when multiple tables are involved in UPDATE... But I need the functionality. Is there a way around this?</p>
  
  <p>A little confused, thanks in advance.</p>