View Single Post
  #1 (permalink)  
Old Mar 1st, 2006, 18:53
roleary roleary is offline
New Member
Join Date: Mar 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Cant figure out the query

Here's the deal. I've got 2 tables:

user
==========
int uid
varchar firstname
varchar lastname

log
==========
int uid
datetime date
varchar page

Every time someone accesses a page on my system, if they're logged in, I create an entry in log with their uid and the url of the page they're accessing.

Now, I'd like to see a list of the last 5 peoples names to access the site. I can't figure out how to write a query to get that.

Sample Data:

user
===============
233 Joe Blow
1150 Tom Sawer
429 Mike Christy

log
===============
233 3/1/2006 7:54:39 AM /trips/payments.asp
233 3/1/2006 7:54:44 AM /trips/whosgoing.asp
233 3/1/2006 7:54:48 AM /login.asp
1150 3/1/2006 8:34:25 AM /trips/payments.asp
1150 3/1/2006 8:34:28 AM /trips/whosgoing.asp
1150 3/1/2006 8:34:36 AM /trips/payments.asp
429 3/1/2006 9:27:22 AM /profile.asp
429 3/1/2006 9:27:35 AM /trips/Default.asp
429 3/1/2006 9:27:38 AM /default.asp


So, what I'd like is:

result
========================
3/1/2006 9:27:38 AM Mike Christy /default.asp
3/1/2006 8:34:36 AM Tom Sawyer /trips/payment.asp
3/1/2006 7:54:48 AM Joe Blow /login.asp


Hope that makes sense.

Thanks in advance for the help.

- O
Reply With Quote