mySQL and node.js how do i use WHERE to get the id of an entry

how can i print the id of jeff bezos. im thinking that i want to take an input of who you want to know the networth, and it use WHERE to find its id, so console.log(result[0].netw); can have a variable for the id, based off of who is put into the WHERE name = "" instead of 0

on.connect(function(err) {     if (err) throw err;     con.query("SELECT * FROM rich WHERE name = 'Jeff Bezos'", function (err, result) {         if (err) throw err;         console.log(result);         console.log(result[0].netw);       });     }); 

Here is what it outputs:

simon@simon-Laptop:~/projects/node/sql$ node where.js [ RowDataPacket { name: 'Jeff Bezos', netw: 153600000000 } ] 153600000000 
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.