![]() |
|
Simple SQL to update Mana usage - Printable Version +- LCKB (https://lckb.dev/forum) +-- Forum: ** OLD LCKB DATABASE ** (https://lckb.dev/forum/forumdisplay.php?fid=109) +--- Forum: Release Zone (https://lckb.dev/forum/forumdisplay.php?fid=190) +---- Forum: General Releases (https://lckb.dev/forum/forumdisplay.php?fid=127) +----- Forum: General Server Releases (https://lckb.dev/forum/forumdisplay.php?fid=212) +----- Thread: Simple SQL to update Mana usage (/showthread.php?tid=4979) |
- Judgement - 11-20-2023 This UPDATE statement will change the a_needMP value in each row of the t_skilllevel table based on the specified conditions. Simple but effective, feel free to use. Could be used in a similar way to adjust exp, gold and and and... UPDATE t_skilllevel SET a_needMP = CASE WHEN a_needMP >= 500 AND a_needMP <= 750 THEN a_needMP * 0.70 WHEN a_needMP > 750 AND a_needMP <= 1000 THEN a_needMP * 0.50 WHEN a_needMP > 1000 AND a_needMP <= 1500 THEN a_needMP * 0.35 WHEN a_needMP > 1500 AND a_needMP <= 2000 THEN a_needMP * 0.25 WHEN a_needMP > 2000 AND a_needMP <= 3000 THEN a_needMP * 0.17 WHEN a_needMP > 3000 THEN a_needMP * 0.03 ELSE a_needMP END; - RGT - 11-25-2023 Yess! really nice statement. Only improvement I have is to include comments and use the "between" Like: UPDATE t_skilllevel SET a_needMP = CASE -- Decrease by 30% for values between 500 and 750 WHEN a_needMP BETWEEN 500 AND 750 THEN a_needMP * 0.70 -- Decrease by 50% for values between 751 and 1000 WHEN a_needMP BETWEEN 751 AND 1000 THEN a_needMP * 0.50 -- Decrease by 65% for values between 1001 and 1500 WHEN a_needMP BETWEEN 1001 AND 1500 THEN a_needMP * 0.35 -- Decrease by 75% for values between 1501 and 2000 WHEN a_needMP BETWEEN 1501 AND 2000 THEN a_needMP * 0.25 -- Decrease by 83% for values between 2001 and 3000 WHEN a_needMP BETWEEN 2001 AND 3000 THEN a_needMP * 0.17 -- Decrease by 97% for values greater than 3000 WHEN a_needMP > 3000 THEN a_needMP * 0.03 -- No change for other values ELSE a_needMP END; Basically just explains the logic for the rages. Easier to understand and the use of "between" makes it a bit more readable if you ask me. Please correct me if I'm wrong! - Scura - 11-29-2023 removed |