database: Simplify selectSQLText() and fix USE INDEX bug

* Previously, using a USE INDEX array with one table string resulted
  in the FORCE INDEX statement not appearing in the SQL.
* Renamed two variables in tableNamesWithUseIndexOrJOIN().

Change-Id: Id084db7df3b07d125ea73faca7e4506a58be5f35
Merge "database: Simplify selectSQLText() and fix USE INDEX bug"