0

I am currently using C# and Mysql (XAMPP). I have 3 tables as shown below:

tblILearnQuestion : IlearnQuestionId, Question

tblILearnAnswer : ILearnAnswerId, ILearnQuestionId, StudentId, dateSubmited

tblILearnMarks : ILearnMarkId, ILearnAnswerId, Comments, mark

I need a single query to get the following data : question, studentid , mark and comment. I have tried this but it does not work:

SELECT * FROM tblIlearnQuestion 
INNER JOIN tblilearnanswer ON 
    tblilearnquestion.ilearnquestionid = tblilearnanswer.ilearnquestionid 
INNER JOIN ilearnmarks ON 
    tblilearnanswer.ilearnanswerid = tblilearnmarks.ilearnanswerid

It says some columns does not exist and I have checked, I did name the columns correctly as it is in my database.

4

2 回答 2

2

看起来您在第二个联接中的表名称错误。您写道您的表名是tblILearnMarks但您在查询中使用了il​​earnmarks。如您所见,缺少tbl前缀。

于 2013-04-27T21:56:38.487 回答
1

您的语法与连接有点不同。这应该可以解决问题:

select * 
from tblIlearnQuestion 
  inner join tblilearnanswer on tblilearnquestion.ilearnquestionid = tblilearnanswer.ilearnquestionid 
  inner join tblilearnmarks on tblilearnmarks.ilearnanswerid = tblilearnanswer.ilearnanswerid
于 2013-04-27T21:57:05.787 回答