如何获得SqLite中的前5条记录?


305

我已经尝试了这没有用。

select top 5 * from [Table_Name]

Answers:




30
select * from [Table_Name] limit 5

12
一分钟为时已晚,您错过了数百次投票
Todd

2
或可能缺少所有大写字母

29

TOP和方括号特定于Transact-SQL。在ANSI SQL中,使用LIMIT和反引号(`)。

select * from `Table_Name` LIMIT 5;

5
LIMIT不是ANSI SQL。ANSI SQL方式仅获取第一5行。同样,双引号用于定界标识符,例如“ Table_Name”。
jarlh 2015年

25
select price from mobile_sales_details order by price desc limit 5

注意:我有mobile_sales_details表

句法

select column_name from table_name order by column_name desc limit size.  

如果您需要最高低价,只需从订单中删除关键字desc


4
Select TableName.* from  TableName DESC LIMIT 5

2
使用不当DESC。没有效果。
EliadL
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.