0
0
SQLquery~5 mins

TOP vs LIMIT across databases in SQL - Quick Revision & Key Differences

Choose your learning style9 modes available
Recall & Review
beginner
What does the TOP keyword do in SQL?
TOP limits the number of rows returned by a query, commonly used in SQL Server and MS Access.
Click to reveal answer
beginner
What is the purpose of the LIMIT clause in SQL?
LIMIT restricts the number of rows returned by a query, commonly used in MySQL, PostgreSQL, and SQLite.
Click to reveal answer
beginner
How do you write a query to get the first 5 rows in SQL Server?
Use: SELECT TOP 5 * FROM table_name;
Click to reveal answer
beginner
How do you write a query to get the first 5 rows in MySQL?
Use: SELECT * FROM table_name LIMIT 5;
Click to reveal answer
intermediate
Can TOP and LIMIT be used interchangeably in all SQL databases?
No. TOP is mainly for SQL Server and MS Access, while LIMIT is for MySQL, PostgreSQL, and SQLite. They are not interchangeable across all databases.
Click to reveal answer
Which SQL keyword is used to limit rows in MySQL?
AROWNUM
BTOP
CLIMIT
DFETCH
How do you get the first 10 rows in SQL Server?
ASELECT TOP 10 * FROM table;
BSELECT * FROM table WHERE ROWNUM <= 10;
CSELECT * FROM table FETCH FIRST 10 ROWS;
DSELECT * FROM table LIMIT 10;
Which database commonly uses the LIMIT clause?
AMySQL
BSQL Server
COracle
DMS Access
Is the following query valid in PostgreSQL? SELECT TOP 5 * FROM users;
AOnly if LIMIT is also used
BYes
COnly with a special extension
DNo
Which keyword is NOT used to limit rows in standard SQL?
ATOP
BSELECT
CLIMIT
DFETCH
Explain the difference between TOP and LIMIT in SQL and name which databases commonly use each.
Think about which keyword you use in SQL Server vs MySQL.
You got /3 concepts.
    Write example queries to get the first 3 rows from a table named 'employees' using both TOP and LIMIT.
    Remember TOP goes after SELECT, LIMIT goes at the end.
    You got /2 concepts.