fix sql query for register