- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can the rows be sorted out in a meaningful way?
For sorting the rows in a meaningful way we can use ORDER BY clause. Suppose we want to sort the rows of the following table −
mysql> Select * from Student; +--------+--------+--------+ | Name | RollNo | Grade | +--------+--------+--------+ | Gaurav | 100 | B.tech | | Aarav | 150 | M.SC | | Aryan | 165 | M.tech | +--------+--------+--------+ 3 rows in set (0.00 sec)
The query below sorted the table by ‘Name’.
mysql> Select * from student order by name; +--------+--------+--------+ | Name | RollNo | Grade | +--------+--------+--------+ | Aarav | 150 | M.SC | | Aryan | 165 | M.tech | | Gaurav | 100 | B.tech | +--------+--------+--------+ 3 rows in set (0.00 sec)
The query below sorted the table by ‘Grade.
mysql> Select * from student order by Grade; +--------+--------+--------+ | Name | RollNo | Grade | +--------+--------+--------+ | Gaurav | 100 | B.tech | | Aarav | 150 | M.SC | | Aryan | 165 | M.tech | +--------+--------+--------+ 3 rows in set (0.00 sec)
- Related Articles
- How a list can be sorted in Java
- Python – Filter Sorted Rows
- Count all sorted rows in a matrix in C++
- Maximum number of partitions that can be sorted individually to make sorted in C++
- C++ Program to find out the number of unique matrices that can be generated by swapping rows and columns
- How can Tensorflow be used to sum specific elements/rows of a matrix in Python?
- Check if array can be sorted with one swap in Python
- How can I eat rice in a healthy way?
- Check if a queue can be sorted into another queue using a stack in Python
- MySQL random rows sorted by a specific column name?
- Find the Kth Smallest Sum of a Matrix With Sorted Rows in C++
- How can we get the sorted MySQL output?
- Program to find out how many boxes can be put into the godown in Python
- Find alphabetical order such that words can be considered sorted in C++
- Can I find out the next auto_increment to be used?

Advertisements