What is the proper syntax of the keyword LIMIT to display 8 results after starting at record 3?
Explanation
Get an explanation when it's available:
Theory
  • The SQL TOP clause is used to fetch a TOP N number or X percent records from a table.
    Note: All the databases do not support TOP clause. For example MySQL supports LIMIT clause to fetch limited number of records and Oracle uses ROWNUM to fetch limited number of records.

    Syntax:

    The basic syntax of TOP clause with SELECT statement would be as follows:
    SELECT TOP number|percent column_name(s)
    FROM table_name
    WHERE [condition]
    
    Read more: SQL - TOP, LIMIT or ROWNUM Clause
  • Example:

    Consider the CUSTOMERS table having the following records:
    
    | ID | NAME     | AGE | ADDRESS   | SALARY   |
    +----+----------+-----+-----------+----------+
    |  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
    |  2 | Khilan   |  25 | Delhi     |  1500.00 |
    |  3 | kaushik  |  23 | Kota      |  2000.00 |
    |  4 | Chaitali |  25 | Mumbai    |  6500.00 |
    
    Following is an example on MySQL server, which would fetch top 3 records from CUSTOMERS table:
    
    SQL> SELECT * FROM CUSTOMERS
    LIMIT 3;
    
    This would produce the following result:
    
    | ID | NAME    | AGE | ADDRESS   | SALARY  |
    +----+---------+-----+-----------+---------+
    |  1 | Ramesh  |  32 | Ahmedabad | 2000.00 |
    |  2 | Khilan  |  25 | Delhi     | 1500.00 |
    |  3 | kaushik |  23 | Kota      | 2000.00 |
    
    Read more: SQL - TOP, LIMIT or ROWNUM Clause

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
SQL quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes