SQL 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 CustomerName FROM Customers
ORDER BY CustomerID ASC;
MySQL 语法
SELECT column_name FROM table_name
ORDER BY column_name ASC
LIMIT 1;
实例
SELECT CustomerName FROM Customers
ORDER BY CustomerID ASC
LIMIT 1;
Oracle 语法
SELECT column_name FROM table_name
ORDER BY
column_name ASC
WHERE ROWNUM <=1;
实例
SELECT CustomerName FROM Customers
ORDER BY CustomerID ASC
WHERE ROWNUM <=1; |