Mysql query help: sorting before updating
I've searched online for a solution and didn't find anything specific to my problem. Stackoverflow is a great source, btw.
The desired outcome will make updates to all level 1, then level 2, 3, 4 and up. This query does not do this. Is there a way to make the query sort by level first then apply updates? Code:
update loottable_copy,npc_types set mincash = floor(0.2 * (pow(`level`,2)) - 3 * `level` + 5) |
Hmm... what is the mincash expression you're trying to apply to the records?
The one above results in a negative number for levels 2 through 13, which is likely not intended. |
EDIT: `mincash` is the minimum amount of copper coins which will drop from a given loottable
Perhaps it's considered sloppy writing to not encapsulate columns with accented quotes. Point taken. Ah, thanks for the tip. The warning I was was receiving was based directly from the result being signed and datatype being unsigned. Need to get my hands on a graphing app to conceptualize better. I'm pretty close to resolution. I reworded my searches and found something that seems to work at a general level. Updated query Code:
update (select `level`,loottable_id,race,name from npc_types order by `level` asc) npc Thanks Shendare |
Cool. Glad you got it where you wanted it.
Looks like that results in the following: Quote:
|
Thank you sir.
Not quite what I wanted but pretty close. The lower levels are pretty inconsequential anyways. I've tweaked the math in it to <(floor(0.17 * (pow(`level`,2)) - `level` +5))> and the results are a little better, and no need for abs with this change. |
All times are GMT -4. The time now is 12:59 PM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.