I have a two tables which are linked by a one-to-many relationship. Now I need to sort the rows based on the key which I have in my first table.
For Ex
TeacherID StudentID
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
2 9
2 10
2 11
2 12
If I sort the Rows based on by teacherID, the student id’s are changing for each and every execution.
In the result set the studentID are changing in the random order. Now I need the studentID‘s not to be changed.
Is there anything I can do, to solve this problem without using sort by the studentID column.
You can sort on both.
Selecting data from any database engine without specifying an
ORDER BYdoesn’t guarantee any order at all.