What is the proper syntax of the keyword LIMIT to display 5 results after starting at record 4?
Explanation
Get an explanation when it's available:
Theory
  • 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
  • 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

Updated. Thanks, @pomanitz

2016 Aug 31, 3:39:29 PM

LIMIT is not SQL. It's using for MySQL... In SQL u can limit rows like this: SELECT TOP 3 * FROM product;

2016 Jul 4, 10:30:56 AM

Follow CodeGalaxy

Mobile Beta

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