MySQL存储过程if语句

时间:2011-12-28 09:32:44

标签: mysql stored-procedures

DECLARE vote_id INT;
    select id from votes where votes.question_id = question_id and vote_type_id = 3 into vote_id;

    if vote_id is null then
      ...do A
    else
      ...do B
    end if;

条件应为true并执行代码的一部分但始终执行B部分 如何使用if语句选择?非常感谢你。

1 个答案:

答案 0 :(得分:1)

尝试select id from votes where votes.question_id = question_id and votes.vote_type_id = 3 into vote_id;

相关问题