List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:November 19 2002 5:55pm
Subject:RE: simple question
View as plain text  
At 11:37 -0600 11/19/02, Carter, Scott wrote:
>There might be ten different records with a fname of scott and the dates
>might be 2002-11-18, and 2002-11-10 and 2002-10-15.  When the query results
>are returned the ORDER BY clause seems to have no effect on the results.  I
>would want the record with the most current date to be returned first, then
>second most current date ...

You're describing your results, not showing them.  That's not helpful.

If you're saying that ORDER BY has *no* effect, then do these two
queries produce identical results?

SELECT fname, lastused FROM PROFILES where fname="scott" ORDER BY lastused;
SELECT fname, lastused FROM PROFILES where fname="scott";

Let's see the output from these queries.

>
>The question is really pretty simple,

Yes, it is.  And the answer is that you should use ORDER BY.  But you're
not providing the information necessary to determine whether it's working
correctly, or whether it's just not working the way you expect -- which
may well be a completely different thing.  In fact, from your description
in the first paragraph, it sounds like you want ORDER BY lastused DESC
and not just ORDER BY lastused.  That will sort with the greatest (most
recent) date first.  Without DESC, the least (least recent) date will
appear first.

>  I just need to know how in MySQL can I
>order my query results in chronilogical order based on a column of date
>type.  This is an application where  I write the date a user signs on into
>the database, and when the users are queryed I need to show the newest user
>first.
>
>Thanks - Scott Carter

Thread
simple questionScott Carter19 Nov
Re: simple questionPaul DuBois19 Nov
RE: simple questionScott Carter19 Nov
RE: simple questionPaul DuBois19 Nov
RE: simple questionScott Carter19 Nov
RE: simple questionPaul DuBois19 Nov
RE: simple questionScott Carter19 Nov
  • RE: simple questionKaruna Bhavnani19 Nov