#测试mysql函数能否少传参数
DELIMITER //
DROP FUNCTION test//
CREATE FUNCTION test(a char(20),b char(20))
RETURNS char(20)
BEGIN
declare ret char(20);
if a is null then
set ret="null";
else
set ret="not null";
end if;
return ret;
END
//
DELIMITER ;
#返回值
mysql> select test(a="2");
1054 - Unknown column 'a' in 'field list'
mysql> select test("2");
mysql> select test("2","1");
+---------------+
| test("2","1") |
+---------------+
| not null |
+---------------+