Page 1 of 1

select closest to most current time

Posted: Fri Jan 16, 2004 4:12 pm
by linuxbox
i have an sql table below that i'm trying to select the most current entry based on the number in the timestamp field. can someone post code on how to do that? i need it for displaying the "currently logged in users" and the most current file they've viewed. the number in the timestamp field is generated using the time() function:

timestamp ip2 file2 username2
1074289944 x.x.x.x http://url.php admin
1074289960 x.x.x.x http://url.php admin
1074289935 x.x.x.x http://url.php admin

thank you!

hmm

Posted: Fri Jan 16, 2004 6:30 pm
by linuxbox
man i wish someone knew how to do this, i'm freak'n lost.

Posted: Fri Jan 16, 2004 6:58 pm
by McGruff
The most current is the highest value so:

"SELECT MAX(timestamp) as timestamp FROM table"

right

Posted: Fri Jan 16, 2004 7:30 pm
by linuxbox
McGruff wrote:The most current is the highest value so:

"SELECT MAX(timestamp) as timestamp FROM table"
i understand that but i'm not just selecting MAX(timestamp)..i need to select everything in two tables including the MAX(timestamp) from the 2nd table.