CREATE DATABASE loan_data;
USE loan_data;
CREATE TABLE loan_user (
id long,
amount long
);
INSERT INTO loan_user(id, amount)
values (1,7000), (2,7000), (3,5000);
DELIMITER $$
CREATE PROCEDURE loan_check()
BEGIN
DECLARE a int;
select a = count(amount) from loan_user where amount=7000;
print a;
END $$
DELIMITER ;
CALL loan_check();
DROP DATABASE loan_data;
I want to print the a variable in the above code. But the code returns
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'a;
END' at line 5
How to fix this?