1
MySQL Stoaredプロシージャでは、ローカル変数にベロークエリの結果を格納します。UNIONクエリの結果をMYSQLストアドプロシージャのローカル変数に保存
MySQLのSP Iは、ローカル変数にクエリの結果を渡すことができますどのように
BEGIN
Declare temp_ID bigint;
Declare temp_teamName Text;
(select ID,team1 from tbl_tournament_matches where leveID = 1 and tournamentID = 91 and matchType = 'L')
UNION
(select ID,team1 from tbl_tournament_matches where leveID = 2 and tournamentID = 91 and looserTeam is not null)
ORDER BY RAND() LIMIT 0,1;
select temp_ID, temp_teamName;
END;
? 注:上記のSPは1行だけを返します。