MySQL问题与if和其他语句

时间:2020-04-26 21:01:01

标签: mysql phpmyadmin

在MYSQL中创建过程时,我遇到了一个问题,因为条件运行'IF'语句,并且也运行'ELSE'语句。只是因为在'IF'中插入了一个语句。

insert into Userverified  (UserID, Mobile, PIN,uname,unameid)           
select NextUserID(),Mobile,PIN,null,null from UserNotVerified where Mobile=p_Mobile;

总是结果---“结果00” ---为什么?

如果我删除此

insert into Userverified  (UserID, Mobile, PIN,uname,unameid)           
select NextUserID(),Mobile,PIN,null,null from UserNotVerified where Mobile=p_Mobile;

工作正常。

im使用PhpMyAdmin,MYsql新。 附加为---

的代码
 CREATE procedure test      
(      
p_Mobile  varchar(13),      
p_LastOTP varchar(6)      
)          
begin   
 if ((select count(*) from UserVerified where mobile=p_Mobile)=0)      
 then 
  insert into Userverified  (UserID, Mobile, PIN,uname,unameid)           
  select NextUserID(),Mobile,PIN,null,null from UserNotVerified where Mobile=p_Mobile;

  if((select count(*) from uwallet where mobile=p_Mobile)=0) 
  then
  insert into UserWallet (WalletID,Mobile,JoinAmount,WinAmount,ReferAmount,TotalAmount,DateModified)
  select nextwalletid(),p_Mobile,0,0,0,0,now();
  end if;

  select 1 as result;      
 else      
select '00' as result;       
 end if;            
end;

0 个答案:

没有答案