Order by Clause in MySQL || MySQL Tutorial || Code With Neha

preview_player
Показать описание
The MySQL Order by statement

The ORDER By statement is used to sort the result-set in ascending or descending order.

The ORDER BY statement sorts the records in ascending order by default. To sort the records in descending order, use the DESC keyword.

ORDER BY Syntax

SELECT column1, column2, ...
FROM table_name
ORDER BY column1, column2, ... ASC|DESC;

Let's apply this in mysql

Here I am using previously created database order_info
Within this database there are 2 different tables orders and Customers

We will use orders table for example

Select * from orders
Order by OrderID;

This query will show the table in ascending order with respect to OrderId

Similarly order by customer ID or orderdate will sort the table in ascending order of customer Id or orderdate

To sort it in descending order add Desc

Now to order by several columns

Select * from orders
Order by orderID,Orderdate;

Note that the columns mention just after the order by clause will get most importance in the query

To sort it in desc order add desc to the query

So that's all for today Hope you all will get some help from this video
If it's so then don't forget to subscribe my channel Code with Neha and press the Bell Icon for Regular Updates
See you in the next video till then Stay Safe Stay Happy

#orderbyclauseinsql
#sqlorderby
#sqlorderbyclause
#orderbyclause
#orderbyclauseinsql
#orderbyclauseinoracledatabase
#sqlorderbykeyword
#useorderbywithwhereclauseinsql
#orderbyclauseinsqlascending
#sqlorderbyclauseexamples
#sqlorderbymultiplecolumns
#sortrecordsofcolumnsinsqlusingorderby
#sortrecordsusingorderbyinsql
#orderbyascendingorderinsql
#orderbyinsqlexplained
#sqlorderbyclausetutorial
#orderbyinsql
#orderbyvssortby
#orderbyclause
#whatisorderbyclause
#howtouseorderbyclauseinsql
#clausesinsql
#mysqlorderbyclause
#clausesmysql
#orderbyclauseinmysqlworkbench
#orderbyclauseexplained
#orderbyclauseexamples
Рекомендации по теме