0

I have table with 3 columns: "FirstCol", "SecondCol" and "ThirdCol". I need to sort table by "FirstCol".

I know that I can sort table using SELECT:

SELECT * FROM `TableName` ORDER BY `FirstCol` DESC

But this way only works when I output data.

I need to sort the rows in the table itself. That is, the rows will be stored sorted in the database file.

closed as off-topic by Colin 't Hart, mustaccio, McNets, Max Vernon, LowlyDBA Jan 15 at 20:57

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Too localized - this could be because your code has a typo, basic error, or is not relevant to most of our audience. Consider revising your question so that it appeals to a broader audience. As it stands, the question is unlikely to help other users (regarding typo questions, see this meta question for background)." – mustaccio, McNets, Max Vernon
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 4
    There is no way to sort data in the table. You save to sort in with the select query. – Mr Zach Jan 12 at 15:08
  • But if you want to do this for performance reasons, many DBMSes can use an index to avoid sorting. If SQLite supports this, an index on “FirstCol” will help. – Colin 't Hart Jan 12 at 15:15
  • 1
    Not sure if this helps but check this link – Sam Jan 12 at 15:28

Browse other questions tagged or ask your own question.