Meaning "?" in mysql query

I've seen some (my) sql queries written like this:

SELECT ? + 4;

      

What is the meaning ?

? I am assuming that this is some kind of parameter, but how to determine its value?

+3


source to share


2 answers


?

is a placeholder for parameter values ​​in the syntax for prepared statements . The linked article gives the following example:

mysql> PREPARE stmt1 FROM 'SELECT SQRT(POW(?,2) + POW(?,2)) AS hypotenuse';
mysql> SET @a = 3;
mysql> SET @b = 4;
mysql> EXECUTE stmt1 USING @a, @b;
+------------+
| hypotenuse |
+------------+
|          5 |
+------------+
mysql> DEALLOCATE PREPARE stmt1;

      



Since you also noted , it deserves a reference to the prepared statement Wikipedia article for further reading regardless of MySQL.

+8


source


In mysql, a ?

is a placeholder in a prepared post . It will be replaced with any value associated with the client before executing the statement.



+3


source







All Articles