Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

node-mysql

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
like image 550
Sean McClory Avatar asked May 26 '15 11:05

Sean McClory


People also ask

What is double question mark in SQL?

To keep such question marks in a SQL statement from being interpreted as positional parameters, use two question marks (??) as an escape sequence. You can also use this escape sequence in a Statement, but that is not required. Specifically only in a Statement a single (?) can be used as an operator.

What is question mark in mysql query?

The question mark represents a parameter that will later be replaced. Using parameterized queries is more secure than embedding the parameters right into the query. SQL Server calls this parameterize queries, and Oracle calls it bind variables.

What does double question mark mean in PHP?

In PHP 7, the double question mark(??) operator known as Null Coalescing Operator. It returns its first operand if it exists and is not NULL; otherwise, it returns its second operand. It evaluates from left to right.

What is the meaning of double question mark?

The double question mark is also used in cases when we want to highlight something while asking. Example: “Is that your cupboard or a pile of garbage??” “Didn't you hear me when I said let's go??” and “Who steals a pen??”


1 Answers

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

like image 101
Barmar Avatar answered Oct 23 '22 11:10

Barmar