从来没接触过mysql
在通过phpmyadmin运行脚本出错,百思不得其解,大家能否帮忙看看
脚本如下use test;
CREATE DEFINER=`root`@`localhost` PROCEDURE `job_all_count`(IN departments text,IN locations text)
BEGIN
SELECT COUNT(*) AS counter FROM m_job_job WHERE department = departments AND `location`=locations AND status=1;
END$$报错
#1064 - 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 'END$$' at line 3 隔断符是分号

解决方案 »

  1.   

    use test;
    CREATE DEFINER=`root`@`localhost` PROCEDURE `job_all_count`(IN departments text,IN locations text)
    SELECT COUNT(*) AS counter FROM m_job_job WHERE department = departments AND `location`=locations AND status=1;
      

  2.   

    use test;
    CREATE DEFINER=`root`@`localhost` PROCEDURE `job_all_count`(IN departments text,IN locations text)
    BEGIN
    SELECT COUNT(*) AS counter FROM m_job_job WHERE department = departments AND `location`=locations AND status=1;
      

  3.   

    use test;
    CREATE DEFINER=`root`@`localhost` PROCEDURE `job_all_count`(IN departments text,IN locations text)
    SELECT COUNT(*) AS counter FROM m_job_job WHERE department = departments AND `location`=locations AND status=1
      

  4.   

    楼上的两位多谢啦 这个是可以的 不过能不能解释一下为什么去掉begin end就可以呢?
      

  5.   

    而这句就不行呢,真是奇怪就多两个参数
    CREATE DEFINER=`root`@`localhost` PROCEDURE `job_all_page`(IN departments text,IN locations text,IN jbpage int,IN jboffset int)
    SELECT id,Description,Qualification,updatetime,position,department,location FROM m_job_job WHERE department = departments AND `location`= locations AND status=1 LIMIT jbpage,jboffset;
      

  6.   

    超过两句需要用 begin end;并且需要用 delimiter 来指定新的结束符。
      

  7.   

    错误提示是语法错误
    弄了半天都没搞明白,结果把mysql从5.0升到5.6还是5.5忘记了
    就莫名其妙的好了,mysql的bug也不少呀