I have a database with the following structure:
ID LEVEL MOVE NUMBER VALUE
1 1 1 123
1 1 2 345
I am recording the variable "value" with javascript and sending it to the database via PHP. What I need to do is build an SQL query to update the table by autoincrementing the column "move number". However, this should occur conditional on the columns values "ID" and "Level". This means that if a player with ID=2 plays level 1, the database should update as:
ID LEVEL MOVE NUMBER VALUE
1 1 1 123
1 1 2 456
2 1 1 789
The same goes for the variable level. In the end, say we have a total of 3 players, two levels and 2 moves, the database should look like:
ID LEVEL MOVE NUMBER VALUE
1 1 1 123
1 1 2 456
2 1 1 789
3 1 1 012
1 2 1 345
2 1 2 678
...
Grouping by either id or level is not important in this case. The important thing is that each move is recorded sequentially together with its value. As I am not so much familiar with SQL syntax, I am unsure how to achieve this