Small sql maintenance

Two minor SQL-related fixes:

 - Delete Database after MySQL test (and ignore errors upon creation)
 - Replace a subquery with a join