Is it possible to use substitution variables (single-ampersand "&" like in Oracle) in MySql queries?
If so, how can you handle it with php?
| SitePoint Sponsor |
Is it possible to use substitution variables (single-ampersand "&" like in Oracle) in MySql queries?
If so, how can you handle it with php?
Never ascribe to malice,
that which can be explained by incompetence.
Your code should not look unmaintainable, just be that way.
In oracle you can do this:
SELECT employee_id, last_name, salary, department_id
from employees
where employee_id = &employee_num;
When you run this query it will ask you for a value for the variable &employee_num.
It is an interactive way to input values. And, I would like to know if it is possible to do the same in MySQL.
And how do you handle that with PHP?
Hi,
I haven't seen such a possibility in MySQL yet. But if you have the user input in some PHP variable, you can create a dynamic SQL:
PHP Code:$employee_num = 5;
$sql = "SELECT employee_id, last_name, salary, department_id
FROM employees WHERE employee_id = " . $employee_num;
Never ascribe to malice,
that which can be explained by incompetence.
Your code should not look unmaintainable, just be that way.
Bookmarks