Fix the bug that uses select twice in the SQL statement.