I'm new to node and javascript. Sorry if this is an obvious question.
I retrieve data from mysql using the node,js code below:
var quer = connection.query('select password from users where mail="'+ so +'" ',function(err, result, fields){
console.log(result);
});
Result is this
[{password:'123456'}]
I want to get it as only 123456, how can I achieve that?
arb
7,8847 gold badges35 silver badges67 bronze badges
asked Feb 16, 2014 at 17:26
Manohar Gunturu
1254 silver badges16 bronze badges
1 Answer 1
It's easy:
console.log(result[0].password)
answered Feb 16, 2014 at 18:20
Jaroslav
2,3531 gold badge14 silver badges10 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-js
resultis an array that contains an object with a password, it's not JSON. Soconsole.log(result[0].password)should do it.