gpt4 book ai didi

MySQL 函数返回多于 1 行

转载 作者:可可西里 更新时间:2023-11-01 07:21:28 24 4
gpt4 key购买 nike

我想编写一个返回多行数据的 MySQL 存储函数。这可能吗?它似乎被锁定在 1 行——甚至无法返回 0 行。

例如

DELIMITER //create function go()RETURNS intdeterministicNO SQLBEGINreturn null ; -- this doesn't return 0 rows!  it returns 1 row-- return 0 ;END //DELIMITER ;

虽然从 MySQL 存储过程返回 null,但不会返回 0 行。它返回 1 行,其中包含值 null

我可以从 MySQL 函数返回 0 行或多于 1 行吗?

最佳答案

来自 MySQL 引用:

23.4.6: Can MySQL 5.0 stored routines return result sets?

Stored procedures can, but stored functions cannot. If you perform an ordinary SELECT inside a stored procedure, the result set is returned directly to the client. You need to use the MySQL 4.1 (or above) client-server protocol for this to work. This means that—for instance—in PHP, you need to use the mysqli extension rather than the old mysql extension.

关于MySQL 函数返回多于 1 行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2891884/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com