What's the proper query for this. (needs orderby, make some of the values be last and more) MYSQL

Patrick John Calumno

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)

enter image description here

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.

scaisEdge

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.

edited at
0

Comments

0 comments
Login to comment

Related

which php\mysql query is more proper

Make a table with a MySQL query with multiple values in some fields

What's the best way to insert values into their "proper" place in a pandas dataframe by some (index) parameter?

What's the proper way to execute some logic in reactor if I'm expecting empty values?

What's the proper way to make the AppBar fixed?

How to use more advanced parameters on Doctrine query builder's 'orderBy()'?

Is there a way to make this MySQL query more efficient?

Mysql Query needs clarification

MySQL Query Needs Optimization?

MySQL Orderby a number, Nulls last

Chronicle Values: What's the point if it still needs to allocate an instance on heap?

What's the proper syntax to query a string in google sheets?

What's the proper way to write hex literal values in Delphi?

Mysql query to proper Laravel $query

What's the proper way to store this data in a MySQL schema?

What is the proper name given to MySQL's Linear Hash algorithm?

How to make proper UPDATE query?

MySql replace what's after the last /

Error `The code you are testing needs to make 1 more call(s)` in testify package

What should i do more to make it display the variables instead of the values?

What is the proper query for the update statement?

Make a fullsite mysql search query, searching more than 1 table

MySQL - Query not returning proper results

Ansible - What's the proper syntax for loop + zip when combining more than two lists?

Is it possible to generate a MYSQL query of more tables with values of one table column as more query columns?

MYSQL - Get values from the last id in a group by query

MySQL Count + GroupBy & OrderBy and Last Record

What's wrong with the data?? Showing NaN values though having values and not displaying the proper labels

MYSQL has orderBy on count(*) some impact on perfomance?