如何反转 MySQL 查询的输出顺序 [英] How to reverse order output of MySQL query

查看:97
本文介绍了如何反转 MySQL 查询的输出顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基本的写入和检索 SQL 数据库 PHP东西";我想按降序输出.我该怎么做?

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?

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

E.g. 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会以升序显示结果,如果你想以相反的顺序显示它们 put 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 或 date 作为字段名称

You can use id or date as the field name

这篇关于如何反转 MySQL 查询的输出顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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