How to sort the MySql Database?

后端 未结 2 2049
陌清茗
陌清茗 2021-01-24 01:48

I have stored various records in the MySql database \"orkut\". Now I want to sort that database through a java program. I have connected to the database through the jdbc driver.

2条回答
  •  我在风中等你
    2021-01-24 02:37

    Don't try to sort this through Java--you'll kill yourself trying. SQL has an order by clause that does exactly this. Here's the SQL:

    select
        number,
        sr_no
    from
        tbl
    order by
        number desc
    

    Also note that you cannot have a permanently sorted database. The way that the data is stored does not lend itself to being stored in whatever order you choose. You should never count on the order of a database to be the same, unless you use an order by in your query.

提交回复
热议问题