fix bug in sql.