WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

SQL FIRST() Function


The FIRST() Function

The FIRST() work restores the main estimation of the chose column.

SQL FIRST() Syntax

SELECT FIRST(column_name) FROM table_name;

Note: The FIRST() work is just upheld in MS Access.


SQL FIRST() Workaround in SQL Server, MySQL and Oracle

SQL Server Syntax

SELECT TOP 1 column_name FROM table_name
ORDER BY column_name ASC;

Example

SELECT TOP 1 CustomerName FROM Customers
ORDER BY CustomerID ASC;

MySQL Syntax

SELECT column_name FROM table_name
Request BY column_name ASC
LIMIT 1;

Example

SELECT CustomerName FROM Customers
ORDER BY CustomerID ASC
LIMIT 1;

Oracle Syntax

SELECT column_name FROM table_name
WHERE ROWNUM <=1
ORDER BY column_name ASC;

Example

SELECT CustomerName FROM Customers
WHERE ROWNUM <=1
ORDER BY CustomerID ASC;

Database

In this instructional exercise we will utilize the database.

Below is a determination from the "Clients" table:

CustomerID CustomerName Phone Address City Country
1

Ramonita Homan 231-596-2048 ORubaiyat Road Terrific Rapid MI USA
2 Charles L. Emmons 507-256-8113 Rosewood Court Clarks Grove MN USA
3 Ruth C. Dorsey 079 1763 2524 Quay Street NAILBRIDGE YO4 5SS UK
4

Evelyn B. Blacker 077 6011 6540 Wade Lane SAND HOLE YO4 5SS UK
5 Nytorpsv채gen 45 Christina Berglund Nytorpsv채gen 45 BANKERYD Sweden

SQL FIRST() Example

The following SQL proclamation chooses the primary estimation of the "CustomerName" section from the "Clients" table:

Example

SELECT FIRST(CustomerName) AS FirstCustomer FROM Customers;