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我有错误。当我删除上述if条件时,其余的存储过程工作正常。
我在if语句中收到多个或条件的错误。
请帮忙。
答案 0 :(得分:2)
您错过了OR
。尝试:
IF region='Mumbai' OR region='Chennai' OR region='Bangalore' OR region='Pune' OR region='Coimbatore' OR region='Ahmedabad' THEN
另外,我认为IN
也适用于此(由于我不经常使用MySQL,我不能100%确定):
IF region IN ('Mumbai','Chennai','Bangalore','Pune','Coimbatore','Ahmedabad') THEN
如果MySQL对它感到满意,那将更具可读性。