Get the App
SLTechnology News&Howtos  ›  Database  › 

Can the mysql function pass fewer parameters (not in person)

Shulou Source: shulou.com Published: 2022-06-01 11:30:38 09月26日 Update

#Test whether mysql function can pass fewer parameters

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 ;

#Return value

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 |

+---------------+

Tags: Functions parameters tests Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Huawei Linux Shulou Tech Info MariaDB