Fix our custom UPDATE TABLE call for local_id to work with mysql
Our special sql statement for setting the local_id based on a maximum of the
other local_ids in the table or 1 didn't work with mysql. This is because mysql
doesn't allow you to update a table and select from it at the same time. This is
fixable by selecting the results into a derived table and then selecting the
match from that.
Was able to post a review with a local site on a server using mysql. Unit tests
also run, so this works with sqlite as well.