View Single Post
  #12  
Old 12-22-2003, 08:32 PM
r2d2atemyhomework
Fire Beetle
 
Join Date: Dec 2003
Posts: 10
Default

Quote:
Originally Posted by Muuss
since you know sql code, you could just make a short fix by yourself (at least for your own use if you need it), of the kind :

update npc_types set maxdmg=9 where level=1;
update npc_types set maxdmg=14 where level=2;

...
I actually already did and things are running great now.

In mysql you can't do a subselect in an update when the subselect queries the table you are updating, so I had to break it in to two queries. The first grabs the average and the second updates the maxdmg. It will only update rows with maxdmg equal to 400. Obviously you will have to do this manually for each level or write a script/app to do it for you. Here's the SELECT query which gets the average, in this case for level 1:

Code:
select ROUND(AVG(maxdmg)) from npc_types where level = 1 and maxdmg <> 400;
Then take the average returned by the query above and set maxdmg to it. In this update, the average was 4 for level 1:

Code:
update npc_types set maxdmg = 4 where level = 1 and maxdmg = 400;
Reply With Quote