How to ask MySQL to prompt for values in a query?
lima-city → Forum → Programmiersprachen → PHP, MySQL & .htaccess
-
I am doing a lot of trial and error with some SQL query in MySQL console e.g.
select fname, age, address from person where lname = ?;
I want to get a prompt asking me for the value of lname, so that I can repeat the query with different values easily. The ? works in case the query is from Java code.
Is it possible in MySQL console, if yes, how? -
Diskutiere mit und stelle Fragen: Jetzt kostenlos anmelden!
lima-city: Gratis werbefreier Webspace für deine eigene Homepage
-
That's just not possible directly within SQL. You need some kind of a program to do that.
The question mark is a so called "parameter marker" for SQL where a program could give the SQL to MySQL without directly knowing which exact parameter will be there on execution but the database could already "prepare"/compile the SQL. On execution the program then gives the real parameter which substitutes the question mark. -
Diskutiere mit und stelle Fragen: Jetzt kostenlos anmelden!
lima-city: Gratis werbefreier Webspace für deine eigene Homepage