What is the difference between single ( ? ) and double question mark ( ?? ) in node-mysql?

人盡茶涼 提交于 2020-05-08 06:47:10

问题


Am sure this is fairly obvious, to me it would make more sense if the second double question mark in the example was a single one.

From their docs:

Alternatively, you can use ?? characters as placeholders for identifiers you would like to have escaped like this:

var userId = 1;
var columns = ['username', 'email'];
var query = connection.query('SELECT ?? FROM ?? WHERE id = ?', [columns, 'users', userId], function(err, results) {
  // ...
});

console.log(query.sql); // SELECT `username`, `email` FROM `users` WHERE id = 1

回答1:


?? is used for table and column names, it escapes them with backticks. ? is for ordinary values.



来源:https://stackoverflow.com/questions/30457086/what-is-the-difference-between-single-and-double-question-mark-in-n

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!