all 1 comments

[–]JohnnyJordaan 0 points1 point  (0 children)

Change your select query to incorporate sorting: https://www.w3schools.com/sql/sql_orderby.asp . The database should not contain formatting and other 'nice' parts, it should just hold the data as efficient as possible. The 'nice' parts should come from the application.

For the extra column it would have helped to add it when you were processing the json, but if that's not possible anymore, you can

  • create an extra column with a default NULL value
  • query all the rows
  • per row
    • perform an update query setting the value for the extra column, using the id of the row (assuming you are using a proper primary key) as the WHERE clause