I have one master table (teacher) structured like
teacherId Name Class
1 Praveen 10
2 John 9
and having a child table (student) structured like
studentId teacherId Name
1 1 David
2 1 Creg
3 2 Mike
4 2 Steve
5 2 Jim
How I can get a result set like
teacherId teacher studentId_1 student_1 studentId_2 student_2 studentId_3 student_3
1 Praveen 1 David 2 Creg null null
2 John 3 Mike 4 Steve 5 Jim
Thanks in advance..
Regards, Praveen
SELECT t.teacherId, t.Name, s.studentId, s.Name FROM teacher t JOIN student s ON t.teacherId=student.teacherId– ppeterka Oct 17 '12 at 7:56