MySQL get variable from SELECT
- by rlb.usa
MySQL keeps saying my syntax is incorrect.
I want to do this:
DELIMITER $$
DROP PROCEDURE IF EXISTS `myprocedure` $$
CREATE DEFINER=`db`@`%` PROCEDURE `myprocedure`(
var_name varchar(10)
)
BEGIN
/* syntax errors below */
DECLARE countTemp integer;
SET countTemp=(SELECT COUNT(Name) FROM mytable WHERE Name= var_name);
/* more stuff */
END $$
DELIMITER ;
What's the correct syntax?