如何使用if来测试mysql中的值是否在列表中?

如何使用if来测试mysql中的值是否在列表中?,mysql,iif-function,Mysql,Iif Function,以下是程序中的部分代码: if p_vendor_id is null then set v_msg := 'Error: parameters are not valid' elseif p_vendor_id not in (select vendor_id from p_plants.vendors) then set v_msg := 'Error: vendor id parameter is not a vendor in our tables' 如果…不在

以下是程序中的部分代码:

if p_vendor_id is null then set v_msg := 'Error: parameters are not valid'
    elseif p_vendor_id not in (select vendor_id from p_plants.vendors) then
        set v_msg := 'Error: vendor id parameter is not a vendor in our tables'
如果…不在,则我在else中遇到语法错误。如何测试值是否在列表中


谢谢

语法不正确,应该使用分号,如果


文档中有一个例子:

您能分享整个错误吗?
if p_vendor_id is null then set v_msg := 'Error: parameters are not valid';
elseif p_vendor_id not in (select vendor_id from p_plants.vendors) then
    set v_msg := 'Error: vendor id parameter is not a vendor in our tables';
end if;