您的位置:程序门 -> 其他数据库开发 -> mysql/postgresql



请大哥大姐们帮帮我,求一个存储过程


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


请大哥大姐们帮帮我,求一个存储过程
发表于:2007-12-20 10:38:17 楼主
我需要一个mysql存储过程,用来验证用户登陆的,查询语句如下

select   count(*)   from   user   where   name=p_name   and   password=p_password

希望是有2个传入参数,传入用户名和密码,判断查询结果是否为0,返回0或1
发表于:2007-12-20 12:51:531楼 得分:0
declare   cnt   int   default   0;
select       count(*)       from       user       where       name=p_name       and       password=p_password   into   cnt;
if   cnt   >   0   then
else
end   if;
发表于:2007-12-24 13:26:252楼 得分:0
delimiter   $$
drop   procedure   if   exists   `procchecklogin`   $$
create   procedure   `procchecklogin`(p_name   varchar(20),p_password   varchar(20))
begin
declare   inum   int;
select
            count(*)   into   inum
from
            `user`
where
            (   `name`   =   p_name   )
            and(   `password`   =   p_password   );
if   inum   >   0   then
select   1   as   result;
else
select   0   as   result;
end   if;
end   $$
delimiter;


快速检索

最新资讯
热门点击