自定义返回出来的是什么值?
自定义返回的是什么值?ASCII还是他的什么值i?
这是表:
mysql> SELECT * FROM test;
-> //
+------+------+--------+
| id | name | typeid |
+------+------+--------+
| 1 | 22 | 1 |
| 2 | 11 | 1 |
| 3 | 44 | 3 |
+------+------+--------+
3 rows in set (0.16 sec)
这是自定义函数:
CREATE FUNCTION
-> myfstfun_2(in_id VARCHAR(20),in_str1 VARCHAR(20),in_str2 VARCHAR(20))
-> RETURNS VARCHAR(5)
-> BEGIN
-> DECLARE int_1 INT;
-> DECLARE int_2 INT;
-> IF (in_id IS NOT NULL) THEN
-> SELECT typeid INTO int_1
-> FROM test
-> WHERE id=in_id AND name=in_str1;
-> SELECT typeid INTO int_2
-> FROM test
-> WHERE id=in_id AND name=in_str2;
-> END IF;
-> RETURN int_1 + int_2;
-> END//
这是返回值:
mysql> SELECT myfstfun_2('4','4','2');
-> //
+-------------------------+
| myfstfun_2('4','4','2') |
+-------------------------+
| NULL |
+-------------------------+
1 row in set (0.03 sec)
为什么是null?
表示还没怎么弄懂!!!求解,谢谢!