Wednesday, June 5, 2024
 Popular · Latest · Hot · Upcoming
72
rated 0 times [  79] [ 7]  / answers: 1 / hits: 27068  / 8 Years ago, thu, june 30, 2016, 12:00:00
connection.query('
SET @update_id := 0;
UPDATE relations set x1 = ?, y1 = ?, id = (SELECT @update_id := id) WHERE element_to =?;
SELECT @update_id;',[data.x2,data.y2,id],function(err,result){
if(err){console.error(err);}
else{console.log(result);console.log(result.@update_id);}
});


I am getting the following result from a query execution:



[ RowDataPacket {
'@update_id': 'WAbWA1WA5WA2WA8WAdWA4WA9' } ] ]


How do I access the @update_id field to store the value in a variable. I know these are objects and I tried the following to access them such as follows:



results.@update_id; 


But I get undefined when I try to log the value. How to get the value?


More From » mysql

 Answers
43

Try this:



results[0].@update_id

[#61559] Wednesday, June 29, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tonisandyp

Total Points: 694
Total Questions: 97
Total Answers: 77

Location: British Indian Ocean Territory
Member since Tue, Feb 22, 2022
2 Years ago
;