2016-04-01 37 views
-2
IF region='Mumbai' OR region='Chennai' OR region='Bangalore' OR region='Pune' region='Coimbatore' OR region='Ahmedabad' THEN 
      SET region='South-west'; 
     ELSE 
      SET region='North+East'; 
     END IF; 

我想创建一个sp,我在上面的Condition中有错误。当我删除上面的条件时,其余的存储过程工作正常。存储过程中的if .... else中的多个条件

我收到错误的多个或条件在if语句。

请大家帮忙。

回答

2

您错过了OR。尝试:

IF region='Mumbai' OR region='Chennai' OR region='Bangalore' OR region='Pune' OR region='Coimbatore' OR region='Ahmedabad' THEN 

另外,我觉得一个IN将在这里工作,以及(我不是100%肯定,因为我不经常使用的MySQL):

IF region IN ('Mumbai','Chennai','Bangalore','Pune','Coimbatore','Ahmedabad') THEN 

这将是更如果MySQL对此感到满意,则可读。

+0

哦!傻我谢谢你的帮助 –