...

Sorting MySql results

Chris Hunter
10-30-2002, 12:42 PM
Hey Guys!

I want to sort the results from a MySql Command by a certain row.

e.g. I want to display the coloumn with the lowes timestamp first or i want to display only the latest entry in the result array. I fetch my results like that:

$result=mysql_query("SELECT * FROM $wp_start")
$num=mysql_numrows($result);

Somewone has a short hint?

i really need just a very tiny - tiny - icy - littely - hinti - pinty
never mind the last sentence. im allready wired.

btw: the page im working on is : http://www.kummerkaestchen.com/pics

maybe anybody could move this thread to mySql Board. I just realized it better on that board.

bcarl314
10-30-2002, 12:53 PM
Add "ORDER BY" to your SQL based on the field you want to sort.

SELECT * FROM $wp_start ORDER BY myField

Use "DESC" to reverse the sort

SELECT * FROM $wp_start ORDER BY myField DESC

Gbright
10-30-2002, 01:07 PM
Originally posted by Chris Hunter
or i want to display only the latest entry in the result array

to get just the latest entry with an sql command, use the following...

SELECT * FROM $wp_start ORDER BY timestampfield DESC limit 1

Chris Hunter
10-30-2002, 01:43 PM
cool my friends - thanks a lot



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum