Fix SQL query for sets.