Hi, I am using SQLite 3.11. I create a table as follows:
CREATE TABLE MyTable (F1 INTEGER, F2 INTEGER, F3 INTEGER); Then add the following records: INSERT INTO MyTable (F1, F2, F3) Values (1, 2, 8); INSERT INTO MyTable (F1, F2, F3) Values (1, 3, 9); INSERT INTO MyTable (F1, F2, F3) Values (2, 4, 8); INSERT INTO MyTable (F1, F2, F3) Values (2, 5, 2); INSERT INTO MyTable (F1, F2, F3) Values (3, 6, 4); INSERT INTO MyTable (F1, F2, F3) Values (3, 7, 8); INSERT INTO MyTable (F1, F2, F3) Values (4, 2, 4); INSERT INTO MyTable (F1, F2, F3) Values (4, 2, 6); Now if I want to select from MyTable, and sort the result based on F1 (ascendant), and for two records with same F1, then sort based on F2(ascendant), then sort based on F3(ascendant) should I use the following : SELECT * FROM MyTable ORDER BY F1, F2, F3? I check https://www.sqlite.org/lang_select.html#orderby and it said ?Rows are first sorted based on the results of evaluating the left-most expression in the ORDER BY list, then ties are broken by evaluating the second left-most expression and so on.? So based on my understanding, my statement is correct. Moreover, since the sort will be performed frequently, to improve the performance, I want to add a field F4, then update the table so that all the records will have a unique F4 value which is the order sequence based on the above order by clause, thus if I want to select again, I do not need to use ORDER BY F1, F2, F3 any more, instead, I can use: SELECT * FROM MyTable ORDER BY F4 Is that feasible? If yes, how do to that? Thanks