select closest to most current time

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
linuxbox
Forum Newbie
Posts: 18
Joined: Fri Dec 12, 2003 5:16 pm

select closest to most current time

Post 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!
linuxbox
Forum Newbie
Posts: 18
Joined: Fri Dec 12, 2003 5:16 pm

hmm

Post by linuxbox »

man i wish someone knew how to do this, i'm freak'n lost.
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

The most current is the highest value so:

"SELECT MAX(timestamp) as timestamp FROM table"
linuxbox
Forum Newbie
Posts: 18
Joined: Fri Dec 12, 2003 5:16 pm

right

Post 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.
Post Reply