SORTING RESULTS



MySQL - Sorting Results


Sorting query results is re-arranging the rows returned from a query result set either in ascending or descending order. The DESC keyword is used to sort the query result set in a descending order. The ASC keyword is used to sort the query result set in an ascending order.


Syntax :

SELECT <field1, field2,...>
FROM <table_name>
ORDER BY <field1, field2,...> ASC|DESC

  • We can sort returned result set on any column provided.

  • We can sort the result set on column or columns.

  • ASC or DESC keyword is used to get the result in ascending order or descending order accordingly.Default is ascending order.


    Example :


    SELECT StudentName,StudentClass
    FROM studentinfo
    ORDER BY StudentName,StudentClass ASC
    

    The result will be displayed as follows:
    (As we noticed Names are ordered according to ascending order of alphabets)


    StudentNameStudentclass
    Ajaashitenth
    manjusixth
    Manjushasixth
    Meherishsixth
    Noothansixth
    Sahayanasixth
    Sweekruthasixth


    MySQL TRIGGERS

    MySQL - Triggers

    posted on 2019-11-29 21:44:07 - mysql Tutorials


    Grant_ Revoke Privilege

    MySQL - Grant_ Revoke Privilege

    posted on 2019-11-26 23:15:04 - mysql Tutorials


    MySQL Vs SQL

    MySQL Vs SQL

    posted on 2019-11-25 05:02:26 - mysql Tutorials


    What Is Oracle

    What Is Oracle

    posted on 2019-11-29 01:11:21 - ORACLE Tutorials


    TRIGGER

    ORACLE - Trigger

    posted on 2019-11-28 22:14:22 - ORACLE Tutorials


    CURSOR

    ORACLE - Cursor

    posted on 2019-11-28 22:13:54 - ORACLE Tutorials