Question

Referencing: SET user defined variable in mysql return null?

I tested the following code:

SET @rank=0;
SELECT *, @rank:=@rank+1 AS rank FROM points

For points in PhpMyAdmin it returns:

id | user_id | points | rank
-----------------------------
2  | 133845  | 220    | 1
4  | 134084  | 220    | 2
5  |      1  | 150    | 3
7  | 134086  | 145    | 4


HOWEVER in SQLYog all the ranks return as "NULL" I checked my configs and set timeout to 28800 seconds and turned off compression protocol. MySQL seems to stay on one single session but SQLYog seems to be using two connections for this query. How can I set the application to one single connection so I don't lose the variable values?

Was it helpful?

Solution

Multiple queries within one instance. They're being stacked in individual instances.

As Jan suggest "Execute all statements" command should do the trick.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top