Here is a simple scenario with table characters:
CharacterName GameTime Gold Live Foo 10 100 3 Foo 20 100 2 Foo 30 95 2
How do I get this output for the query SELECT Gold, Live FROM characters WHERE name = 'Foo' ORDER BY GameTime:
Gold Live 100 3 0 -1 -5 0
using MySQL stored procedure (or query) if it’s even possible? I thought of using 2 arrays like how one would normally do in a server-side language, but MySQL doesn’t have array types.
While I’m aware it’s probably easier to do in PHP (my server-side langauge), I want to know if it’s possible to do in MySQL, just as a learning material.
One possible solution using a temporary table:
Of course Eoin’s solution is better if your id column follows the order you want in the output.