changed back SQL queries to use % notation for string substitution