Mysql function call

前端 未结 4 869
伪装坚强ぢ
伪装坚强ぢ 2021-02-10 04:34

If I call a function several time then will it execute every time or just execute once and the value will be used then after several time? Example:

 select my_fu         


        
4条回答
  •  不思量自难忘°
    2021-02-10 05:20

    It's very simple to run the MySQL function.

    Login to MySQL command prompt using command:

    $> mysql -u root -p
    

    Then use the database using:

    mysql> use database_name
    

    Then run the MySQL function using:

    mysql> delimiter //
    
    mysql> CREATE PROCEDURE simpleproc (OUT param1 INT)
        -> BEGIN
        ->   SELECT COUNT(*) INTO param1 FROM t;
        -> END//
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> delimiter ;
    
    mysql> CALL simpleproc(@a);
    Query OK, 0 rows affected (0.00 sec)
    

    Instead of procedure we can add any multiple line function in above example.

提交回复
热议问题