Table: Users, Students, Groups
Users:
Rows: Username
Values: Teacher1
, Teacher2
, Teacher3
, Teacher4
Students:
Rows: grpID
, Name
Values: (1, John), (1, Joe), (1, Rose), (2, Gina), (2, Mark), (2, Jack), (3, Ted), (4, Fred)
Groups:
Rows: grpID
, Handler
Values (1, Teacher1), (2, Teacher2), (3, Teacher3), (4, Teacher4)
I want to query that when someone is logged in (let's say Teacher1)
Select `Name` from Students where (I don't know the proper condition here) Order by `Name`
but here's the result that I want:
Fred
Gina
Jack
Mark
Ted
Joe
John
Rose
I want those 3 students handled by Teacher1 (as example user who logged in) to be the last record to be shown on the result of the query.
Somethings loke this
select `name` from Students
inner join Groups on Students.groupID = Groups.grpID
where groups.Handler = 'Teacher1'
order by `name`;
otherwise if you want the students order by name you simply use
Select `name` from Students
order by `name`;
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments