Answer the question
In order to leave comments, you need to log in
How to display two lines in one?
There is (for example) a table matches and match_opponents.
Match_opponents has match_id and opponent_id (for each match there are two opponents, i.e. for match = 123 there will be two lines with match id and opponent id).
Select *
from matches m
inner join match_opponents op on op.match_id = m.match_id
where m.status like "started";
Answer the question
In order to leave comments, you need to log in
Use grouping
select
m.match_id,
min(opponent_id) as op1, max(opponent_id) as op2
from match_opponents op
inner join matches m on op.match_id = m.match_id
where m.status = "started"
group by m.match_id;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question