In message <[EMAIL PROTECTED]>, Bob
<[EMAIL PROTECTED]> writes
>Hi Pete,
>I'm using a mysql database.

Then, you never 'sort' (your word) a MySQL database.  You make it appear
in a different sequence of records (i.e., 'appear sorted') by using
indexes.

>What I am doing is getting just the date of the latest message left, which 
>displays on a previous page.
>i.e. Last message was posted: date time etc.
>
>SELECT *, UNIX_TIMESTAMP(logged) AS logged FROM forum ORDER BY logged DESC 
>LIMIT 
>1
>
>I though I should be using MAX(logged) somehow, but can't get it to work.

Max(logged) will get you the maximum value of logged as a field.  I
suppose that, doing it that way, you would need 
SELECT *, UNIX_TIMESTAMP(logged) AS logged FROM forum WHERE
logged=max(logged);
... it ought to work, perhaps more slowly (perhaps not!), but it just
*feels* wrong.

>I'll stick with the above for now.

Good idea.  

If you are going to ask for this latest message frequently, you will
need an index on logged, of course.  This will slow adding data by a
tiny fraction, but will allow you to retrieve data much faster.

>Regards, Bob.

-- 
Pete Clark

http://www.hotcosta.com
http://www.spanishholidaybookings.com




Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to