Im trying to use the sql SELECT SUM to get the sum of a column.
When I use
Code:
resultMaps = dbi_query(dbcMaps,"SELECT SUM(difficulty) FROM skillmaps where steamId='%s' AND mapName='%s'",authid,mapname)
I get a "[MYSQL] Invalid column name 'difficulty'".
When I tested
Quote:
SELECT SUM(difficulty) FROM `skillmaps`
|
in phpmyadmin I get the sum.
When I change the code to
Code:
resultMaps = dbi_query(dbcMaps,"SELECT difficulty FROM skillmaps where steamId='%s' AND mapName='%s'",authid,mapname)
I get acces to the column difficulty? How do I get that summed up value in my plugin?
The part of my function which dont work below:
Code:
// Get the sum of collected points
new qryDifficulty[10]
resultMaps = dbi_query(dbcMaps,"SELECT SUM(difficulty) FROM skillmaps where steamId='%s' AND mapName='%s'",authid,mapname)
if (resultMaps <= RESULT_FAILED ) {
log_amx("[AMXX: SKILLRANK] Couldnt sum difficulty. Plugin cancelled.")
return PLUGIN_HANDLED
}
dbi_nextrow(resultMaps)
dbi_result(resultMaps, "difficulty", qryDifficulty, 9)
len += format(mapStatsMotd[len], 2047-len,"Collected rank points on this map: %i^n",qryDifficulty)
dbi_free_result(resultMaps)