Query a connection object without parameters
suggest changeYou send the query as a string and in response callback with the answer is received. The callback gives you error
, array of rows
and fields. Each row contains all the column of the returned table. Here is a snippet for the following explanation.
connection.query('SELECT name,email from users', function(err, rows, fields) {
if (err) throw err;
console.log('There are:', rows.length,' users');
console.log('First user name is:',rows[0].name)
});
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents