How to get Top 5 records in SqLite?

SqliteSelect

Sqlite Problem Overview


I have tried this which did not work.

select top 5 * from [Table_Name]

Sqlite Solutions


Solution 1 - Sqlite

SELECT * FROM Table_Name LIMIT 5;

Solution 2 - Sqlite

An equivalent statement would be

select * from [TableName] limit 5

http://www.w3schools.com/sql/sql_top.asp

Solution 3 - Sqlite

select price from mobile_sales_details order by price desc limit 5

Note: i have mobile_sales_details table

syntax

select column_name from table_name order by column_name desc limit size.  

if you need top low price just remove the keyword desc from order by

Solution 4 - Sqlite

TOP and square brackets are specific to Transact-SQL. In ANSI SQL one uses LIMIT and backticks (`).

select * from `Table_Name` LIMIT 5;

Solution 5 - Sqlite

select * from [Table_Name] limit 5

Solution 6 - Sqlite

Select TableName.* from  TableName DESC LIMIT 5

Solution 7 - Sqlite

Replace only YOUR table name[TABLE_NAME] and use.

"select * from "+TABLE_NAME+ " LIMIT " +5;

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAmitabhView Question on Stackoverflow
Solution 1 - SqliteNixView Answer on Stackoverflow
Solution 2 - SqliteChris JView Answer on Stackoverflow
Solution 3 - SqliteBharathirajaView Answer on Stackoverflow
Solution 4 - SqlitenewtoverView Answer on Stackoverflow
Solution 5 - SqliteYOUView Answer on Stackoverflow
Solution 6 - SqliteSGDemoView Answer on Stackoverflow
Solution 7 - SqliteAndroidView Answer on Stackoverflow