如何在MYSQL数据库上具有逆序输出 [英] How to have reverse order output on MYSQL database

查看:568
本文介绍了如何在MYSQL数据库上具有逆序输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对sql数据库php"thing"进行了基本的写入和检索,我希望输出以降序排列.我怎么做?

I have a basic write to and retrieve sql database php "thing" and I want to have the output in descending order. How do I do that?

例如.首先显示最后一个条目,然后显示之前的条目,然后显示该条目之前的...第一个条目是最后一个.

Eg. last entry is shown first, then entry before that, then entry before that... first entry ever is last.

推荐答案

SELECT field_name
FROM table_name 
ORDER BY id DESC

默认情况下,如果要以相反的顺序显示结果,mysql将以升序显示结果.ORDER BY field_name DESC

By default mysql Will show results in ascending order if you want to show them in reverse order put ORDER BY field_name DESC

您可以使用id或日期作为字段名

You can use id or date as the field name

这篇关于如何在MYSQL数据库上具有逆序输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆