I'm developing a social game where the user advances in levels according to their points number.
I want to create an efficient query that changes the user points and then change their level if needed.
The initial query is this:
Code:
"UPDATE users SET points = points + $pointsNum WHERE users.id = $id"
There is a 'levels' table that includes the points needed per level. My questions are:
1. Maybe storing the points per level data in a config file would be better, since there are only 10 levels and the required points will probably not change much during the lifetime of the game?
2. How should I approach the level update situation? should I add it to the existing query or create a separate one?
3. Since there are 10 levels, I will need 10 "BETWEEN"s in the query, to check the current points number vs each points range. Maybe there is a prettier way to do this?
Any help would be appreciated.