WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

SQL SELECT TOP Clause


The SQL SELECT TOP Clause

The SELECT TOP statement is utilized to indicate the quantity of records to return.

The SELECT TOP statement can be valuable on huge tables with a large number of records. Restoring countless can affect on performance.

SQL Server/MS Access Syntax

SELECT TOP number|percent column_name(s)
FROM table_name;



SQL SELECT TOP Equivalent in MySQL and Oracle

MySQL Syntax

SELECT column_name(s)
FROM table_name
Point of confinement number;

Example

SELECT *
FROM Persons
Point of confinement 5;

Oracle Syntax

SELECT column_name(s)
FROM table_name
WHERE ROWNUM <= number;

Example

SELECT *
FROM Persons
WHERE ROWNUM <=5;

Database

In this instructional exercise we utilize the Northwind test database.

Below is a determination from the "Clients" table:

CustomerID FirstName Phone Username Password Email address
1

Robert J. Drake (08) 8335 8518 Homeen1989 oeZie7dud RobertJDrake@teleworm.us
2 Yolanda J. Berry (03) 5344 0422 Ouroor Ieph4Xe2phee MoonLightdining.com.au
3 Laura J. Ridley (08) 8343 7035 Younbuthouse Sugeeha1o LauraJRidley@teleworm.us
4

Linda R. Doyle (02) 6778 4799 Ashery oo3ki3Thudo LindaRDoyle@armyspy.com
5 Priscilla A. Moore (08) 8205 4768 Lumbeavy39 iF0haeGoo PriscillaAMoore@teleworm.us



SQL SELECT TOP Example

The following SQL articulation chooses the three first records from the "Clients" table:

Example

SELECT TOP 3 * FROM Customers;