mysql> set @counter:=0; select @counter:=@counter+1 as rank, user_name, user_editcount into 'count.txt' from user where user_name not in (select ug_user from user_groups where ug_group = 'bot') order by user_editcount desc limit 4000; Query OK, 0 rows affected (0.00 sec) ERROR 1327 (42000): Undeclared variable: count.txt mysql>