[PHP] MySQL and sorting

2002-05-20 Thread Cleeker

Is there a way to extract lets say a bunch of dates from a mysql db, and
the sort them in order from newest to oldest? Also how would you sort
names in alphabetical order?

~Cleeker


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] MySQL and sorting

2002-05-20 Thread Miguel Cruz

On Mon, 20 May 2002, Cleeker wrote:
 Is there a way to extract lets say a bunch of dates from a mysql db, and
 the sort them in order from newest to oldest? Also how would you sort
 names in alphabetical order?

Read the section of the MySQL manual that covers ORDER BY clauses.

miguel


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] MySQL and sorting

2002-05-20 Thread Tyler Longren

The MySQL manual will explain this in great detail.

To sort by date:
SELECT * FROM table ORDER BY date ASC;

for that to work, all the values in date should be a timestamp (ex:
2002052000)

To sort by names:
SELECT  * FROM table ORDER BY name ASC;

If you want reverse the order, replace the 'ASC' with 'DESC'.

Tyler Longren
Captain Jack Communications
www.captainjack.com
[EMAIL PROTECTED]
- Original Message -
From: Cleeker [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, May 20, 2002 9:11 PM
Subject: [PHP] MySQL and sorting


 Is there a way to extract lets say a bunch of dates from a mysql db, and
 the sort them in order from newest to oldest? Also how would you sort
 names in alphabetical order?

 ~Cleeker


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] MySQL and sorting

2002-05-20 Thread Jason Wong

On Tuesday 21 May 2002 10:11, Cleeker wrote:
 Is there a way to extract lets say a bunch of dates from a mysql db, and
 the sort them in order from newest to oldest? Also how would you sort
 names in alphabetical order?

Yes, look at the date/time functions in the (mysql) manual.

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
Not one hundred percent efficient, of course ... but nothing ever is.
-- Kirk, Metamorphosis, stardate 3219.8
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] MySQL and sorting

2002-05-20 Thread David Freeman


  Is there a way to extract lets say a bunch of dates from a 
  mysql db, and the sort them in order from newest to oldest? 
  Also how would you sort names in alphabetical order?

Yes, and a php list is obviously a good place to ask an sql question.

In any case, you want to examine your favourite mysql manual for the
'order by' part, particularly the bit about using 'asc' and 'desc'.

CYA, Dave



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php