title: MySQL table update after in-table comparison
body: <p>Due to a faulty Wordpress/bbPress import, I have duplicate user records, ie "james@foo.com", ID 8 and "imported_james@foo.com", ID 104. </p>
  
  <p>The imported posts have been allocated to ID 104. I would like to change them to 8, so that I can delete all the "imported_%" users. </p>
  
  <p>Is there a query or a simple php script that allows me to perform this in one go? </p>
  
  <pre><code>SELECT  "from", ou.ID, "to", u.ID FROM wp_users u 
  LEFT JOIN wp_users ou ON u.user_email=substring(ou.user_email,10) 
  WHERE ou.ID IS NOT NULL
  </code></pre>
  
  <p>This shows me the old ones and the new ones side by side. But what do I need to do to update the post.author in wp_posts with the new value? </p>