How to ask MySQL about querying values ​​in a query?

I do a lot of trial and error with some SQL query in the MySQL console, for example.

select fname, age, address from person where lname = ?;

I want to get a prompt asking for the lname value so that I can easily repeat the query with different values.? works if the request is executed from Java code.

Is this possible in the MySQL console, if so, how?

0
source share
1 answer

It's impossible.

You might want to create a stored procedure, for example

DELIMITER //
CREATE PROCEDURE GetPerson(p_lname VARCHAR(50))
BEGIN
    SELECT fname, age, address FROM person WHERE lname = p_lname;
END //
DELIMITER ;

and then be able to

mysql> CALL GetPerson('smith');

But that is pretty much as possible.

mysql The goal of the client is to run SQL queries (and manage the service), SQL is a query language that is not intended to interact with the user.

+4
source

All Articles