Reputation: 21
Now I have 2 tables
STUDENT:
STUDENT_ID | STUDENT_NAME | COURSE_ID
1000 | Anson | 1
1001 | Jnson | 1
1002 | Andy | 2
1003 | Alex | 3
COURSE:
COUSE_ID | COURSE_NAME
1 | P5A
2 | P5B
3 | P5C
Now I would like to produce the result to show the students name in each class
Idea result:
P5A P5B P5C
Anson Andy Alex
Jason
what should I do, I am using php + mysql to build web system
Upvotes: 2
Views: 62
Reputation: 51904
select * from course c left join student s on c.course_id = s.course_id
order by c.course_name, c.course_id
Enumerate the result set. Each time course_id changes, start a new section.
Upvotes: 2