PHP Questions Home | Register | Login
Categories
Arrays
Files
Forms
Creating PDFs
PHP Errors
Functions
Images
MySQL
Numbers
Others
Strings
Website
Unanswered

PHP Forums
Forums Index
MySQL Forum
PHP Forum
Flash/Actionscript
Javascript
Web design

More PHP
PHP Functions
Top Questions
Ask a Question
PHP Interview Questions
PHP Jobs
Ecommerce
IT Questions
Business Websites

Sponsors

sponsor ad
My Salary
PHP Developer Salary
Advertise Here

PHP Questions Forums : mySQL Questions and Answers

Jump to Last Post

Ordering results in mySQL

By: Timjohns [15-February-10 3:10PM]
25 posts
picture

Ordering the results in mySQL is pretty easy.

All that you need to do is add ORDER BY and then the fieldname to your query.

For instance, imagine you are getting names from a database.

The simple query might look something like:

SELECT name FROM table

...now if you want to order them alphabetically then you need to do:

SELECT name FROM table ORDER BY name

and that's pretty much all there is to it. To reverse order, just add DESC.

Previous: Picking Data At Random With MySQL Is Easy
Next: Update Not Working For Larger Text Input



Custom Search