I have returned a column of my mysql server(nevermind that they're all the same number...this is jut for testing purposes)
I want all of the numbers in an array...JUST the numbers, not the name of the column 'Northatt'.
below is the code and the result. I've already tried result.northatt, it only returns the first number.
client.query('SELECT Northatt FROM archive', function(err,result){
console.log(result);
});
Result: { Northatt: 23 },
{ Northatt: 23 },
{ Northatt: 23 },
{ Northatt: 23 },
{ Northatt: 23 },
{ Northatt: 23 },
{ Northatt: 23 },
{ Northatt: 23 },
{ Northatt: 23 },
{ Northatt: 23 },
{ Northatt: 23 },
{ Northatt: 23 },
{ Northatt: 23 },
{ Northatt: 23 }..etc.
I just want the numbers.
result is an array of objects. If you just want (the) one value from each of the objects, use .map.
var Northatt = result.map(function(a){
return a.Northatt;
});
Northatt will be an array of just the values.