How do I use the Android sqlite select statement to call up to the last column?

Asked 2 years ago, Updated 2 years ago, 105 views

I'm now using this sql statement to show the data in a list form, but how do I fix this sql statement to show the rest of the data except for the last one in the list?

SELECT * FROM " + TABLE_NAME+" ORDER BY "+USER_TABLE_COLUMN_ID+" DESC

database java android sqlite

2022-09-21 18:45

2 Answers

I understood the meaning of wanting to exclude the last data from the list as the last Row and wrote the answer. Please apply the query statement below. If you say that adding an element automatically increases the _id, then it queries all elements except the last one with the largest _id.

SELECT * FROM table WHERE _id < (SELECT MAX(_id) FROM table);


2022-09-21 18:45

Typically, to select some of the columns, you must specify the columns you want to use in SQL.

SELECT name,phone,email FROM some_table WHERE <condition> ORDER BY <sort> desc

Please specify the names of the columns you want to import in order instead of * as shown in the example above. It is not necessary to follow the order of columns of the table specification (when creating a table), and if necessary, the order of columns may be changed.

Note. There is no SQL grammar specifically to exclude specific columns in a location.


2022-09-21 18:45

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.