MySQL Forums
Forum List  »  Microsoft SQL Server

Order MySQL results
Posted by: Mark Den
Date: March 15, 2012 04:04AM

Overview

You can order MySQL results using "ORDER BY" 1. ORDER BY column_name ASC , 2. ORDER BY column_name DESC, 3. ORDER BY RAND().

1. ORDER BY column_name ASC is order by ascending.
2. ORDER BY column_name DESC is order results by descending.
3. ORDE BY RAND() is order results by random.

If you're not set this up the default is order results by ascending.
Syntax

"SELECT column_name FROM table_name ORDER BY column_name ASC";
or
"SELECT column_name FROM table_name";
- This will select the records from mysql by ascending (ascending is the default value).


"SELECT column_name FROM table_name ORDER BY column_name DESC";
- This will select the records from mysql by descending


"SELECT column_name FROM table_name ORDER BY RAND()";
- This will select the records from mysql by random



Edited 1 time(s). Last edit at 04/10/2012 03:54AM by Mark Den.

Options: ReplyQuote


Subject
Written By
Posted
Order MySQL results
March 15, 2012 04:04AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.