Java 如何从过程中的第二个select语句返回结果集?
如何从第二条select语句返回结果集 我有样品:Java 如何从过程中的第二个select语句返回结果集?,java,mysql,stored-procedures,Java,Mysql,Stored Procedures,如何从第二条select语句返回结果集 我有样品: -- -------------------------------------------------------------------------------- -- Routine DDL -- Note: comments before and after the routine body will not be stored by the server -- -------------------------------------
-- --------------------------------------------------------------------------------
-- Routine DDL
-- Note: comments before and after the routine body will not be stored by the server
-- --------------------------------------------------------------------------------
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `getGender20`(in id INT)
BEGIN
DECLARE str VARCHAR(50);
select @str :=gender from memeber_info where id=id;
if (str = 'Male') then
select '12345' ;
end if;
select '123' ;
END
我的过程是重新调谐
male
,而我需要它返回123
。如何实现这一点?您可以使用case
select case when gender = 'Male'
then 12345
else 123
end as some_name
from memeber_info
where id=id;
在java中,您可以使用函数从
语句
获取下一个结果集。该方法返回一个布尔值,如果有更多可用的结果集,则该值为真。谢谢您的帮助,但我可以在结果中使用第二个选择查询输出吗?如果您正在使用,则可以。不确定其他API。