mysql的if条件控制语句应该怎么用?我想实现如下的功能应该怎么写?
if 10>2 
then 
insert into (省略)
else
select * from users; 
end if 
这样的语句在sql server中是没问题但不知道mysql能这样码

解决方案 »

  1.   

    都是一样的,if语句
    if 条件 then
    end if
      

  2.   

    不在存储过程或函数中能使用if流程控制语句吗? 为什么下面的语句可以
    CREATE DEFINER=`root`@`localhost` PROCEDURE `sy2`()
    begin
    if 10>2 then 
    select "10";
    end if;
    end;但是
    if 10>2 then 
    select "10";
    end if;
    却不行,能单独写带if的语句吗
      

  3.   

    if   10> 2   then
    then   
    insert   into   (省略) 
    else 
    select   *   from   users;   
    end   if   
      

  4.   


    因为在存储过程里面,主体语句需要放在"BEGIN END"语句块里面