I'm using a select statement to pull the data from a mysql server:
client.query('SELECT attend FROM testnumbers WHERE Gym =2', function(err,result){
var jay = result;
console.log(jay);
});
When it returns 'jay', the result is this:
[ { attend: 455 } ]
I want ONLY the number to be in the variable 'jay'. How can I get rid of the other query stuff? Thanks!
What is being returned is called javascript object notation, or JSON. You must parse it. Many ways to extract that data:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse http://api.jquery.com/jQuery.parseJSON/
Plus tons of other tuts on parsing JSON with js.