Reputation: 97
I have a Request table that has some columns. I need to select a row in the table and then use a specific column value(say request_initiator) to search it in another table.
connection.query('SELECT * FROM Requests WHERE `request_id` = ?', req.body.id, function(error,results, fields){}
My results
gives me multiple objects which then contains the component elements with different value.
0
request_id 1
user_id "user1"
from "[email protected]"
to "owner2"
status "deleted"
1
request_id 2
user_id "user4"
from "[email protected]"
to "owner2"
status "pending"
I have to access results
to get from
and then search it in Owners
table.
However, results.from
doesn't give anything. results[0]
gives the first object but I can't access the elements of that list
How should I proceed with this?
Upvotes: 2
Views: 574
Reputation: 50452
results
is a array of multiple objects. You can access the from
key's value using
results[0]["from"]
Upvotes: 2