Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • SELECT TOP Clause in MySQL

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 855
    Comment on it

    The SELECT TOP clause is used to return specific number of records with thousands of records. It is used to select top N number of records from a table. We can use number or percent to select record.

    TOP clause is not supported by all the databases.

    For e.g- MySQL uses LIMIT

                Oracle uses ROWNUM

                MS SQL uses TOP

    1. SELECT TOP:-

    Syntax of SELECT TOP:-

    SELECT TOP number|percent column_name(s)
    FROM table_name WHERE [condition] ;

     

    2.LIMIT:-

    Syntax of LIMIT:-

    SELECT column_name(s)
    FROM table_name
    LIMIT number;

    To display elements in ascending or descending order:-

    SELECT expressions
    FROM tables
    [WHERE conditions]
    [ORDER BY expression [ ASC | DESC ]]
    LIMIT number_rows [ OFFSET offset_value ];

     

    3. ROWNUM:-

    Syntax of ROWNUM:-

    SELECT column_name(s)
    FROM table_name
    WHERE ROWNUM <= number;

    In place of number we will give the number of rows we want to be selected.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: