I am trying to use assigning operator @a := 0 for crossjoin (mysql) in my c# program. But it throws error saying
Fatal error encountered during command execution. Parameter '@a' must be defined.
the below query executes well in my mysql tool. but fails to perform while using it in my C# programming.
string str = "select t1.x1,(@a := @a + t1.x1) x2 from table1 t1 cross join (select @a := 0) params";
MySqlCommand cmd = new MySqlCommand(str, connection);
connection.Open();
cmd.ExecuteNonQuery();
connection.Close();
Output should be:
x1 x2
1 1
2 3
3 6
4 10
5 15
How do i solve this? or is there a work around for this?