PHP HOME
PHP Introduction
PHP SETUP
PHP Syntax
PHP Data Types
PHP Outputs
PHP Variable
PHP Constant
PHP Strings
PHP Operators
PHP if else if
PHP Switch
PHP while loop
PHP for loop
PHP Arrays
PHP Functions
PHP Sorting Array
PHP Form Handling
PHP Form Validation
PHP Form Required
PHP Form URL/EMAIL
PHP Form Submit
PHP Contact Form
PHP DATE & TIME
PHP INCLUDE
PHP FILE HANDLING
PHP FILE OPEN/READ
PHP FILE CREATE/WRITE
PHP FILE UPLOAD
PHP SESSION
PHP COOKIES
PHP FILTER
PHP ERROR HANDLING
PHP EXCEPTION
PHP Redirects
PHP with MySQL
PHP WITH MYSQL DB
MYSQL CONNECT
MYSQL CREATE DATABASE
SELECT DATABASE
MYSQL CREATE TABLE
MYSQL INSERT DATA
MYSQL SELECT DATA
MYSQL UPDATE DATA
MYSQL DELETE DATA
MYSQL ORDER
MYSQL LIMIT
MYSQL LAST ID
MySQL ORDER BY keyword is used to sort the result of a table in ascending or descending order. By default ORDER BY keyword sort the result of a table in ascending order and if you want to sort the result of the table in descending order then you have to MySQL DESC keyword.
SELECT column1, column2, ...
FROM table_name
ORDER BY column1 ASC OR DESC;
There are some examples of ORDER By
SELECT * FROM student ORDER BY student_name;
Above MYSQL QUERY select all the column of student table and sorted by student name in ascending order.
SELECT * FROM student ORDER BY student_name DESC;
Above MYSQL QUERY select all the column of student table and sorted by student name in descending order.
SELECT * FROM student ORDER BY student_name, student_enrollment_no;
Above MYSQL QUERY select all the column of student table and sorted by student name and student enrollment_no in ascending order.
SELECT * FROM student ORDER BY student_name DESC, student_enrollment_no DESC;
Above MYSQL QUERY select all the column of student table and sorted by student name and student enrollment_no in descending order.