Home »
SQL
SELECT TOP with Example in SQL
In this previous article, we learnt about Injection. Now, in this article we are going to discuss about SELECT TOP in SQL.
Submitted by Bharti Parmar, on December 30, 2018
SELECT TOP is used to return the number of records, it is very fast and its performance is very good. It is very useful for the large database having thousands of records.
SELECT TOP is used in different ways in different databases.
Syntax
- MS Access: select top number column_name from table_name;
- MS Access: select top percent column_name from table_name;
- MySQL: select column_name from table_name LIMIT number;
- Oracle: select column_name from table_name where ROWNUM (<=, >=, ==) number;
Example:
Table 1:
Student_ID | Student_Name | Dept | Branch | Course |
15011 |
Aman Gautam |
CSE |
IT |
B.tech |
15028 |
Atul Anand |
CSE |
CS |
B.tech |
15032 |
Bharti Parmar |
CSE |
CS |
B.tech |
15068 |
Partha Biswas |
CSE |
IT |
B.tech |
SQL Query using Oracle Database:
Conclusion:
In this article, we have learned about the SELECT TOP method to retrieve data from the database. It is very useful for retrieving data from the large database. We will know more about SQL in the upcoming article.