how to use SQL- ORDER BY?

Results 1 to 2 of 2

Thread: how to use SQL- ORDER BY?

  1. #1
    ioio Guest

    Default how to use SQL- ORDER BY?

    Hi,<BR>I have a database with a time, a date, a name and a ID column.<BR><BR>I know how to show all of them in ID order. (ORDER BY ID Desc)<BR>But how do I do if I want to show them by date (latest posts)?<BR>or name (a-z) or time?<BR><BR>And on the same page, like if you have a number of posts by ID order and then there are links that you can click on.<BR>Example. click here to view the list by date (latest posts first)<BR>And when you click, its the same page loading but the posts are in a different order.<BR><BR>AND does anyone know how the SQL code is when you want to view THE 5 latest posts from column.<BR>example:<BR>SQL.. SELECT * FROM Users(what shall I write next??)<BR>-----ANYONE KNOW?----<BR><BR>How can you order posts by pages? like, it should only be 10 posts per page. when the 11th post comes, it automatically changes to page 2, and the the 21st comes on page 3 and so and. I would also like to have a next page link and previous page link<BR><BR>Many questions...<BR>ioio<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: how to use SQL- ORDER BY?

    Okay, I am going to try to answer as many of those questions as I can.<BR><BR>First the order by thing...<BR>You can just type, Order by Date DESC or Order By Name DESC and that should fix that.<BR><BR>Secondly, the sql code for the top 5 latest posts is...<BR>SQL.. SELECT top 5 FROM Users Order By date DESC;<BR><BR>

Posting Permissions

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