求基于80级经验值生成81级经验的MySQL插入查询语句
Solution for Inserting Level 81 XP Data
Hey there! Let's get that level 81 experience data inserted correctly. Since we need to calculate it based on the existing level 80 value in your player_xp_for_level table, we can use an INSERT...SELECT statement to pull the current data and compute the new value in one go.
Here's the single SQL query you need:
INSERT INTO player_xp_for_level (Level, Experience) SELECT 81, ROUND(Experience * 1.0115, 0) FROM player_xp_for_level WHERE Level = 80;
A quick breakdown of what this does:
- We're inserting a new row with
Levelexplicitly set to 81 - The
Experiencevalue is calculated by taking the level 80 experience, multiplying by 1.0115, and usingROUND()to convert the result to an integer (since yourExperiencecolumn is an unsigned INT, it can't hold decimal values) - If you'd prefer to always round down or up instead, you can swap
ROUND()withFLOOR()orCEIL()respectively
内容的提问来源于stack exchange,提问作者user5749981
相关产品推荐
相关产品推荐

