This is what i have atm ...
CODE
Table basically like so.
Fixtures
+------------------------------------------------------------------------+
| fixture_id | fixture_team_a | fixture_team_b | fixture_datetime |
+------------------------------------------------------------------------+
Teams
+------------------------------------------------------------------------------+
| team_id | team_division | team_name | team_captain | team_active |
+------------------------------------------------------------------------------+
Fixtures
+------------------------------------------------------------------------+
| fixture_id | fixture_team_a | fixture_team_b | fixture_datetime |
+------------------------------------------------------------------------+
Teams
+------------------------------------------------------------------------------+
| team_id | team_division | team_name | team_captain | team_active |
+------------------------------------------------------------------------------+
My Query:
SQL
(
SELECT fixture_datetime AS fixture_datetime_a, team_id AS team_id_a , team_name AS team_name_a, NULL AS fixture_datetime_b, NULL AS team_id_b , NULL AS team_name_b
FROM scoreboard_fixtures JOIN scoreboard_teams ON scoreboard_teams.team_id = scoreboard_fixtures.fixture_team_a
)
UNION
(
SELECT NULL AS fixture_datetime_a, NULL AS team_id_a , NULL AS team_name_a, fixture_datetime AS fixture_datetime_b, team_id AS team_id_b , team_name AS team_name_b
FROM scoreboard_fixtures JOIN scoreboard_teams ON scoreboard_teams.team_id = scoreboard_fixtures.fixture_team_b
)
SELECT fixture_datetime AS fixture_datetime_a, team_id AS team_id_a , team_name AS team_name_a, NULL AS fixture_datetime_b, NULL AS team_id_b , NULL AS team_name_b
FROM scoreboard_fixtures JOIN scoreboard_teams ON scoreboard_teams.team_id = scoreboard_fixtures.fixture_team_a
)
UNION
(
SELECT NULL AS fixture_datetime_a, NULL AS team_id_a , NULL AS team_name_a, fixture_datetime AS fixture_datetime_b, team_id AS team_id_b , team_name AS team_name_b
FROM scoreboard_fixtures JOIN scoreboard_teams ON scoreboard_teams.team_id = scoreboard_fixtures.fixture_team_b
)
When i run this query i get 2 rows insted of one row, any ideas where im going wrong ... all i basically want is one row per fixture where in that row i have info about both teams and the fixture date.