I have two approaches for executing SQL query in node.js , I want to know the difference between the two. Which one is recommended ? and why ??
First approach
var userId = 1; var columns = ['username', 'email']; var query = connection.query('SELECT ?? FROM ?? WHERE id = ?', [columns, 'users', userId], function(err, results) {
Second approach
var userId = 1; var query = connection.query('SELECT username,email FROM UserTable WHERE id=?', [userId], function(err, results) {
Please tell me the exact use of these two mechanisms.
source share