Re: MySQL: getting latest record

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



you've just about got it in your question.

SELECT * FROM MyTable WHERE Field1='test' OR Field2='test2' ORDER BY
TIMSTAMP DESC LIMIT 1

hth
Jeff


                                                                                                                                       
                      "ShortStay"                                                                                                      
                      <john@shortstay-l        To:       <php-db@xxxxxxxxxxxxx>                                                        
                      ondon.com>               cc:                                                                                     
                                               Subject:   MySQL: getting latest record                                         
                      12/14/2003 10:47                                                                                                 
                      AM                                                                                                               
                                                                                                                                       
                                                                                                                                       




My application is that I am getting the latest quote for a price where more
than one quote may have been made.

I've got a timestamp colum and I want to get the latest record where
certain
columns have certain values.  Eg

SELECT * FROM MyTable WHERE Field1='test' ...?  something about the
timestamp

I may also have an OR in the condition, like WHERE Field1='test1' OR
Field2=test2'...    'test1' and test2' would be different products.

Do I have to use ASCending or DESCending on the timestamp column and LIMIT?

Never done this before so suggestions gratefully received.

Thanks,

John

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux