Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

nodejs mysql getting the id of an inserted row

//If you are inserting a row into a table with an auto increment primary key, you can retrieve the insert id like this:
connection.query('INSERT INTO posts SET ?', {title: 'test'}, function (error, results, fields) {
  if (error) throw error;
  console.log(results.insertId);
});
Source by www.npmjs.com #
 
PREVIOUS NEXT
Tagged: #nodejs #mysql #id #inserted #row
ADD COMMENT
Topic
Name
3+3 =