我有两行:
ID | Name
1 | Adrian
2 | Cheska
我希望能够选择id较低的行,在这种情况下是'Adrian',因为他的ID = 1低于2.如何选择列值较低的行?
答案 0 :(得分:4)
不确定您的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)
答案 1 :(得分:1)
SELECT TOP 1 * FROM <tablename>
ORDER BY ID ASC
答案 2 :(得分:0)
SELECT TOP 1 * FROM table WHERE something = somethingElse ORDER BY ID ASC
答案 3 :(得分:0)
SELECT * FROM table_name d where d.id = (select min(id) from table_name);