Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

For example, the last entry is shown first, then the entry before that, then the entry before that, etc. The first entry ever is last.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
320 views
Welcome To Ask or Share your Answers For Others

1 Answer

Use:

SELECT field_name
FROM table_name
ORDER BY id DESC

By default, MySQL will show results in ascending order. If you want to show them in reverse order, use ORDER BY field_name DESC.

You can use id or date as the field name.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...