想写一个函数aa(1);
当传入参数为不同值时,返时不同的星期。比如:aa(1) 返回'星期一' aa(2)返回 '星期二'drop FUNCTION hello
CREATE FUNCTION hello(s int(10)) RETURNS char(50)
begin
     if s > 100
     //这段语法如何写呢?   
end

解决方案 »

  1.   

    aa(1) 返回'星期一' aa(2)返回 '星期二' aa(3) 返回‘星期三’
      

  2.   


    DELIMITER $$CREATE FUNCTION `t_girl`.`func_hello`(s tinyint(1))
    RETURNS char(3)
    BEGIN
      return 
      case s when 1 then 
        '星期一'
      when 2 then 
        '星期二'
      when 3 then 
        '星期三'
      when 4 then 
        '星期四'
      when 5 then 
        '星期五'
      when 6 then 
        '星期六'
      else 
        '星期天'
      end;
    END$$DELIMITER ;
      

  3.   

    This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its de....在MySQL中创建函数时出现这种错误的解决方法:
    set global log_bin_trust_function_creators=TRUE;