我正在尝试使用this问题中的示例加入三个表格。但是我收到了误差。
错误:
#1054 - Unknown column 'referrer.Referrer_Name' in 'field list'
代码:
SELECT pupils.Pupils_Surname,
pupils.Pupils_FirstName,
referrer.Referrer_Name,
progress_track.test_1,
progress_track.test_2,
progress_track.test_3,
progress_track.test_4,
progress_track.test_5,
progress_track.test_6,
progress_track.test_7,
progress_track.test_8,
progress_track.test_9,
progress_track.test_10
FROM pupils
INNER JOIN progress_track ON progress_track.Progress_Report_Pupils_ID=pupils.Pupils_ID;
INNER JOIN referrer ON pupils.Pupils_Referrer, referrer.Referrer_ID ;
答案 0 :(得分:1)
请删除第一个内连接语句末尾的分号。因为,查询尝试在查询本身的第一个分号后终止语句。因此,这就是列Referrer_Name没有引用表的原因:“referrer”。
原创:
来自学生 INNER JOIN progress_track ON progress_track.Progress_Report_Pupils_ID = pupils。 Pupils_ID; INNER JOIN引用者ON pupils.Pupils_Referrer,referrer.Referrer_ID;
使用此功能:
来自学生 INNER JOIN progress_track ON progress_track.Progress_Report_Pupils_ID = pupils。 Pupils_ID INNER JOIN引用者ON pupils.Pupils_Referrer = referrer.Referrer_ID;
答案 1 :(得分:1)
首先让我突出显示查询中的错误:
1)查询以拼写错误
意外结束 2)最后INNER JOIN
包含语法错误。
我在下面的图片中突出显示了错误:
<强>处理:强>
SELECT
pupils.Pupils_Surname,
pupils.Pupils_FirstName,
referrer.Referrer_Name,
progress_track.test_1,
progress_track.test_2,
progress_track.test_3,
progress_track.test_4,
progress_track.test_5,
progress_track.test_6,
progress_track.test_7,
progress_track.test_8,
progress_track.test_9,
progress_track.test_10
FROM
pupils
INNER JOIN progress_track ON progress_track.Progress_Report_Pupils_ID = pupils.Pupils_ID
INNER JOIN referrer ON pupils.Pupils_Referrer = referrer.Referrer_ID;
回复您的评论:
请你发贴这个作为答案。虽然有效但仍然有效 不显示引荐来源表中的任何数据
LEFT JOIN
。请先检查您的数据。progress_track.Progress_Report_Pupils_ID = pupils.Pupils_ID
referrer.Referrer_ID = pupils.Pupils_Referrer