I searched through various questions but I didn't find an answer. I have a MySQL table 'teams':
+--+----+------+
|id|name|active|
+--+----+------+
|1 |bla |1 |
|2 |blu |0 |
|3 |croc|1 |
|4 |bold|1 |
|5 |foo |1 |
|6 |bar |0 |
+--+----+------+
and a table 'data':
+----+-------+----+
|team|project|time|
+----+-------+----+
|2 |some |1 |
|2 |some2 |5 |
|3 |one |16 |
|3 |one2 |100 |
|5 |more |2 |
|5 |more2 |60 |
+----+-------+----+
In PHP I'm querying the data like this:
SELECT t.name, t.active, d.time
FROM teams t
RIGHT JOIN data d ON (t.id = d.team)
ORDER BY t.id
Everything works find and my result looks like this:
+----+------+----+
|name|active|time|
+----+------+----+
|blu |0 |1 |
|blu |0 |5 |
|croc|1 |16 |
|croc|1 |100 |
|foo |1 |2 |
|foo |1 |60 |
+----+------+----+
...but I want that my result looks like this:
+----+------+---+---+
|name|active|t1 |t2 |
+----+------+---+---+
|blu |0 |1 |5 |
|croc|1 |16 |100|
|foo |1 |2 |60 |
+----+------+---+---+
So... How can I reach this? I hope I have not overlooked an already asked question... :(
Thank you very much!
EDIT: First, thank you all, but I forgot something... It is also possible that e.g. one2 does not exist...