Fix SQL queries.