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

Ad: Are you a blogger? Join our Blogging forum.



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.