How to make the data from the database (table) were taken from the end, not first?
2 answers
ORDER BY - sort by, do you have some kind of field where you guess where the beginning is, where the end is.
- can be more detailed ???? for chayaynika)) - David
- The question is very blurred. What does it mean to take data from the end of the table? approximately it can be implemented so there is a table with such structure Id integer (autoinc) s varchar and so each record S will have its own ID, and we define which record is the first one which is the last. that is, you will need a query like this ** SELECT S FROM TABLE ORDER BY -ID ** to exit will have a list of records in the reverse (according to Id) order. - vdk company
- Thank you! - David
- fourThe relational data model implies that data does not have a natural row order. Those. the order of the rows of any query is determined by the explicit indication of ORDER BY or the result is unpredictable - renegator
- In the database tables there is no beginning and end ... - Yoharny Babai
|
To sort the records in descending order of the value of the ID
field, you can use the following construction:
SELECT * FROM <NAME_TABLE> ORDER BY ID DESC // ID по убыванию или наоборот ID ASС
|