我有两行:
ID | Name
1 | Adrian
2 | Cheska
我希望能够选择具有较低 id 的行,在本例中为“Adrian”,因为他的 ID=1 低于 2。如何选择具有较低列值的行?
不确定您的 RDBMS ..这应该适用于所有 RDBMS
select *
from your_table
where ID in(select min(id) from your_table)
或者
编辑:(根据 a_horse_with_no_name的评论)
select *
from your_table
where ID =(select min(id) from your_table)
SELECT TOP 1 * FROM <tablename>
ORDER BY ID ASC
SELECT TOP 1 * FROM table WHERE something = somethingElse ORDER BY ID ASC
SELECT * FROM table_name d where d.id = (select min(id) from table_name);