我需要为当前用户显示所有灯具(谁玩'反对'谁),所以我编写了 SQL 查询
SELECT
fixture.*
FROM
sport_team_player AS team_player, sport_team AS team
INNER JOIN sport_fixture AS fixture
ON (`team_player`.`team_id` = fixture.`team1_id` OR `team_player`.`team_id` = fixture.`team2_id`)
WHERE
team_player.`team_id` = team.`team_id` AND team_player.`player_id` = '16'
这不起作用并告诉我 team_player.team_id 不存在
但是如果我加入第二个表而不是从多个表中选择它就可以了。
PS。这不是编写此类查询的最佳方式,但它是由 ORM 模块生成的。
编辑:
结果将是夹具数据列表,例如
------------------------------
|fixture_id|team1_id|team2_id|
------------------------------
|1 | 2 | 3 |
------------------------------