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

  1. MS Access: select top number column_name from table_name;
  2. MS Access: select top percent column_name from table_name;
  3. MySQL: select column_name from table_name LIMIT number;
  4. Oracle: select column_name from table_name where ROWNUM (<=, >=, ==) number;

Example:

Table 1:

Student_IDStudent_NameDeptBranchCourse
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:

select top

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.



Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.