'dear all now i'm facing issue with mysql workbench what should i do

00:43:11 create function add_five (@num as int) returns int as begin return( @num+5 ) end Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@num as int) returns int as begin return( @num+5 ) end' at line 1 0.000 sec

MYSQL

create function add_five (@num as int)
returns int
as 
begin
return(
@num+5
)
end;


Solution 1:[1]

Use:

CREATE FUNCTION add_five (num int )
RETURNS INT DETERMINISTIC
       RETURN num + 5;

MySQL CREATE PROCEDURE and CREATE FUNCTION Statements

mysql> CREATE FUNCTION add_five (num int )
    -> RETURNS INT DETERMINISTIC
    ->        RETURN num + 5;
Query OK, 0 rows affected (0.07 sec)

mysql> select  add_five(10);
+--------------+
| add_five(10) |
+--------------+
|           15 |
+--------------+
1 row in set (0.00 sec)

mysql> select  add_five(12);
+--------------+
| add_five(12) |
+--------------+
|           17 |
+--------------+
1 row in set (0.00 sec)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ergest Basha