我可以合并这两个 select 查询吗?

Can i combine these two select queries?

我正在使用两个查询。

首先从特定的 userId 获得 tournament_id。 第二个查询向我提供了有关治疗本身以及锦标赛中其他玩家及其信息的信息。

  #Check if `userId` exists in tournaments if found save the value into a variable.

        SELECT 
            tournament_id
        INTO @tournament_id FROM
            tournament_players
        WHERE
            userId = 5324234;


    #Get information about the tournament itself and which (if any) 
     additional users with there info.

        SELECT 
            *
        FROM
            tournaments AS tour
                JOIN
            tournament_players AS tp ON tour.id = tp.tournament_id
                AND tour.id = @tournament_id;

考虑:

select t.*, tp.*
from trivia_tournaments.tournaments t
inner join tournament_players tp on tp.tournament_id = t.id
where exists (
    select 1
    from tournament_players tp1 
    where tp1.tournament_id = t.id
    and tp1.user_id = ?
)

这将为您提供有关 ? 表示的用户参加的所有锦标赛和玩家的所有可用信息。