From looking at this:
![](https://downloads.intercomcdn.com/i/o/1006559349/b45db23ab98c27220f1e6b05/Screenshot+2024-03-29+at+2_41_45+PM.png)
There is only one value for the key, and it is [0]
. In other words, @i:=0 = [0]
where @i:=0
is the key, and [0]
is the value. We cannot access the index of 2 because there is only one element in the array, that is why you are getting undefined
again.
This is because the query is running a SELECT @i=0
, this is returning the value of @i
when it is assigned (0).
Let's take a step back.
The query that you are running sets the value of the "f12" column in the "letter02" table. For each row, it sets the value of f12 to the current value of @i
and then increments @i
by 10. Essentially, it assigns consecutive values starting from 0 (the initial value of @i
) to the "f12" column in the "letter02" table, with an increment of 10 for each row.
If I am understanding correctly, you would like to get the value of the variable after it has updated all rows. In the case of having 3 rows, that would be 20 (0 -> 10 -> 20).
If this is correct, we will need to create a new query that gets that value of "f12" from the last row, and then we can add it to localStorage.
If your table has an auto-incrementing primary key column, you can use that. Assuming you have a primary key column named id
, the query would be:
SELECT f12
FROM letter02
ORDER BY id DESC
LIMIT 1;
If you name this query "getLastF12", you could run this one on success of the "Test02" query. Then, on success of "getLastF12", we can add the event hander to "Set local storage", and the value would just be {{getLastF12.data["f12"]}}
.