I have 4 tables, three are many to many relationship:
- Student(StudID,GroupId,Name,....)
- Lesson(LessID,LessonName,Mark)
- StudentLesson(StudID,LessID)
and the relationship between student and Group is One to Many
- Student(StudID,Name,....)
- Group(GroupId,GroupNumber)
What I want is how select Name, LessonName, Mark, GroupNumber
select S.Name, L.LessonName, L.Mark, G.GroupNumber from Student s
join StudentLesson SL on SL.StudId = S.StudId
join Lesson L on SL.LessID = L.LessID
Join Group G on G.GroupId = S.GroupId
I think the error in this line Join Group G on G.GroupId=S.GroupId
, because when I omit it, it works between many to many but between one to many it didn't work.