0

如何从第二个选择语句返回结果集

我有样本:

-- --------------------------------------------------------------------------------
-- 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。如何做到这一点?

4

2 回答 2

1

您可以在没有变量的情况下使用case

select case when gender = 'Male'
            then 12345
            else 123
       end as some_name
from memeber_info
where id=id;
于 2012-07-29T19:16:15.237 回答
0

Statement在 java 中,您可以通过使用该getMoreResults函数获得下一个结果集。该方法返回一个布尔值,如果有更多结果集可用,则为真。

于 2012-07-29T20:25:43.203 回答