Get ready for BLACK FRIDAY shopping starting in

Forums

This topic is locked

Distinct Problems

Posted 18 Feb 2003 21:32:48
1
has voted
18 Feb 2003 21:32:48 Scott Kadera posted:
I am trying to select all of the information from one row of a database where one field is "Distinct." My current SQL looks like this:

SELECT DISTINCT track_users_ID
FROM tracking
WHERE track_users_ID = $user
ORDER BY track_date DESC

What I want to do is get the top 10 last viewed pages from the database by a specific user ($user) so I need to pull the user_ID, page_ID, date, etc from the table. Any ideas?

Replies

Replied 18 Feb 2003 22:27:28
18 Feb 2003 22:27:28 Owen Eastwick replied:
SELECT TOP 10 user_ID, page_ID, track_date
FROM tracking
WHERE track_users_ID = $user
ORDER BY track_date DESC

The DISTINCT modifier is pointless if you have a date/time field in the row as every record will be distinct for a given user, they can't be viewing two pages at once can they.


Regards

Owen.

-------------------------------------------------------------------------------------------
Used programming books and web development software for sale (UK only): www.tdsf.co.uk/tdsfdemo/Shop.htm

Developer services and tutorials: www.drdev.net

Multiple Parameter UD4 / Access 2000 Search Tutorial: www.tdsf.co.uk/tdsfdemo/

Reply to this topic