Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Aug 2002
    Location
    Frankfurt/Germany
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Sorting MySql results

    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.
    Last edited by Chris Hunter; 10-30-2002 at 12:45 PM.

  • #2
    Mega-ultimate member
    Join Date
    Jun 2002
    Location
    Winona, MN - The land of 10,000 lakes
    Posts
    1,855
    Thanks
    1
    Thanked 45 Times in 42 Posts
    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

  • #3
    New to the CF scene
    Join Date
    Sep 2002
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Sorting MySql results

    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

  • #4
    New Coder
    Join Date
    Aug 2002
    Location
    Frankfurt/Germany
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    cool my friends - thanks a lot


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •