我是新手不知道这错怎么改delimiter &&
create function student_login_validate(login_name varchar(20),login_password varchar(20))
returns int;
begin
declare num int default=0;
select count(*) into num from StuInfo where stu_id=login_name and pass_word=login_password;
if num!=0
  then return 1;
else return 0;
end if;
end&&源代码如上
 报错: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 ';
begin
declare num int default=0;
select count(*) into num from StuInfo wher' at line 2

解决方案 »

  1.   

    没用过
    但在百度搜到了一个,你看看吧
    http://ispring.iteye.com/blog/218390
      

  2.   

    login_name和login_password  的值是怎么样的?是不是login_name中有单引号?语法问题而已,可以把select count(*) into num from StuInfo where stu_id=login_name and pass_word=login_password;
    这条语句赋值后的结果Print出来看看是怎样的。
      

  3.   

    谢谢同志们 我已经改过来了 拿个例子晾晾:delimiter &&
    create function student_login_validate(login_name varchar(20),login_password varchar(20))
    returns int
    begin
    declare num int default 0;
    select count(*) into num from StuInfo where Stu_Id=login_name and pass_word=login_password;
    if num!=0
      then return 1;
    else return 0;
    end if;
    end&&
      

  4.   

    定义变量的时候, "default = 0;"改为"default 0;"