【问题标题】:how to use if to test whether a value is in a list in mysql?如何使用if来测试一个值是否在mysql的列表中?
【发布时间】:2014-03-24 20:40:45
【问题描述】:

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

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...not in 的语法错误。如何测试一个值是否在列表中?

谢谢!

【问题讨论】:

  • 你能分享整个错误吗?

标签: mysql iif-function


【解决方案1】:

语法不对,应该用分号和end if

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;

文档中有一个例子:http://dev.mysql.com/doc/refman/5.0/en/if.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-11-05
    • 2011-04-09
    • 1970-01-01
    • 2011-12-09
    • 1970-01-01
    • 1970-01-01
    • 2017-12-19
    相关资源
    最近更新 更多