Jump to content

MySQL cell value that depends on other cell values


xQuasar

Recommended Posts

Well, I have a need for one of the cells in mySQL to depend on some other cells.

 

Say, there's a stat, and it depends on the number of weapons. Uhh, jsut for an example, say attack power = 5000 * no. of swords

 

Is there any other way to update attack power, APART from getting the number of swords from mysql, multiplying it by 5000 then changing the attack power cell value to that? Because my game is going to have heaps of weapons. and if i'm going to need to do that... >.>

Create the view as a one-off exercise

CREATE VIEW characterView 
AS 
SELECT swords, 5000*swords AS power
  FROM characterTable;

 

Then, whenever you need to access it, you can select from the view rather than the table

SELECT *
  FROM characterView

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.