mysql用select into给变量赋值出错
我是新手不知道这错怎么改
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
------解决方案--------------------没用过
但在百度搜到了一个,你看看吧
http://ispring.iteye.com/blog/218390
------解决方案--------------------login_name和login_password 的值是怎么样的?是不是login_name中有单引号?语法问题而已,可以把select count(*) into num from StuInfo where stu_id=login_name and pass_word=login_password;
这条语句赋值后的结果Print出来看看是怎样的。