这是我的 MySQL 选择语句,它给了我错误 - 'on 子句'中的未知列'Regattas.regatta_id'
SELECT
Regattas.regatta_id,
Events.event_id,
Events.event_name
FROM Regattas, Events
LEFT JOIN Regatta_Events AS Regatta_Events_1 ON Regatta_Events_1.fk_event_id = Events.event_id
LEFT JOIN Regatta_Events AS Regatta_Events_2 ON Regatta_Events_2.fk_regatta_id = Regattas.regatta_id
WHERE Regattas.regatta_id = {$regattaId}
表的布局如下:
帆船赛表:
+--------------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+--------------+------+-----+---------+----------------+
| regatta_id | int(11) | NO | PRI | NULL | auto_increment |
| regatta_name | varchar(100) | NO | | NULL | |
| regatta_start_date | date | NO | | NULL | |
| regatta_end_date | date | NO | | NULL | |
| regatta_start_time | time | NO | | NULL | |
| regatta_venue_id | int(11) | NO | | 0 | |
+--------------------+--------------+------+-----+---------+----------------+
事件表:
+------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+----------------+
| event_id | int(11) | NO | PRI | NULL | auto_increment |
| event_name | varchar(255) | NO | | NULL | |
+------------+--------------+------+-----+---------+----------------+
像这样的 Regatta_Events 表 - 连词表:
+-------------------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+---------+------+-----+---------+----------------+
| regatta_events_id | int(11) | NO | PRI | NULL | auto_increment |
| fk_regatta_id | int(11) | NO | | 0 | |
| fk_event_id | int(11) | NO | | 0 | |
+-------------------+---------+------+-----+---------+----------------+
请帮我解决这个问题,我已经有一段时间了。