MySQL get variable from SELECT

Posted by rlb.usa on Stack Overflow See other posts from Stack Overflow or by rlb.usa
Published on 2010-05-04T19:06:39Z Indexed on 2010/05/04 19:08 UTC
Read the original article Hit count: 170

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about select