Quote
I’m trying to find all matchData records for a playerId but also getting the matchId of their first match.
To me, that says
two queries, not one.
Whenever you build a query, start by constructing the "rowset" from which you'll read the data (the 'from' and 'join'ing bits), then worry about the data itself (the 'select').
- To get all the records for a given Player, you could get get
lots of rows.
- To get their first match, you'll get only
one (at most).
Trying to mix these two into a
single query will give you major headaches.
Guessing at your table structures (some "create table" statements always help - hint, hint), try these:
select *
from matchData
where playerID = ?
order by kickOff
;
select matchID
, min( kickOff ) kickOff
from matchData
where playerID = ?
group by matchID
;
Regards, Phill W.