fixes correct joining of tables with SELECT as part of the table name

Tables like UserPreselection were not replaced with "UserPreselection". The issing " around table names lead to missing old/new replacement e.g. of versioned tables "UserPreselection" > "UserPreselection_Live". This fix looks explicitly for word SELECT in table name to do correct adding of " at start and end of table name.
adds test for sql query joins and table renaming