SQL queries updated to use string substitution