runoops.com

SQL FIRST() 函数

FIRST() 函数

FIRST() 函数返回指定的列中第一个记录的值。

SQL FIRST() 语法

SELECT FIRST(column_name) FROM table_name;

注释:只有 MS Access 支持 FIRST() 函数。


SQL Server、MySQL 和 Oracle 中的 SQL FIRST() 工作区

SQL Server 语法

SELECT TOP 1 column_name FROM table_name
ORDER BY column_name ASC;
SELECT TOP 1 name FROM Websites
ORDER BY id ASC;

MySQL 语法

SELECT column_name FROM table_name
ORDER BY column_name ASC
LIMIT 1;
SELECT name FROM Websites
ORDER BY id ASC
LIMIT 1;

Oracle 语法

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