Select First in SQL
SELECT FIRST in SQL
Note:
There is no standard SQL SELECT FIRST clause. However, some databases have similar ways to get the "first" row or the top N rows.
How to get the "first" row in different SQL databases:
1. Using LIMIT (MySQL, PostgreSQL, SQLite)
SELECT * FROM table_nameORDER BY some_columnLIMIT 1;2. Using TOP (SQL Server)
SELECT TOP 1 * FROM table_nameORDER BY some_column;3. Using FETCH FIRST (Standard SQL, Oracle 12c+)
SELECT * FROM table_nameORDER BY some_columnFETCH FIRST 1 ROW ONLY;Example: Get first employee by hire date
-- MySQL/PostgreSQLSELECT * FROM employeesORDER BY hire_dateLIMIT 1;If you want to retrieve the "first" row according to some ordering, use one of these approaches depending on your database.
Want examples for your specific database?