donglin5770 2012-06-21 14:26
浏览 265
已采纳

PHPmyAdmin并对数据库表进行排序

[edit]: I'm terribly sorry for my timing on asking this question. I've just discovered that you can use the command

"ORDER BY `table`.`table_col` DESC" 

to order your results from a MySQL table.

I am working on creating forum and I am using ajax to get results from a database table. I would like to order these results before I display them on the page, sorted by a timestamp of the current day of the month.

the day for each post is a two digit number in my MySQL table i.e. 06 for post one, 09 for post two, 21 for post 3

I know how to write the script to sort these, but I would like to know if there is an easier way.

Can I simply set the table in my phpMyAdmin to keep each post sorted in order from least to greatest on the value of the day column?

  • 写回答

2条回答 默认 最新

  • doujue9767 2012-06-21 14:30
    关注

    Indexes and Keys have an order, and often selecting from a table gives results in the order of the index/key relevant to the query.

    That, however, is not always the case.

    In SQL, no matter what you do to the table, the result set can come out in a completely different order.

    For that reason, the only way to guarantee the order of the results is to specify an ORDER BY in the query.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作