Well, it is important to remember that SELECT DISTINCT simply restricts that the WHOLE ROW is distinct, therefore it takes into account all columns, not just the sessionID column, when deciding if a row is distinct.
One way to do this would be to do SELECT sessionID, userID, date, time FROM sti_tracking WHERE sessionID IN (SELECT DISTINCT sessionID FROM sti_tracking WHERE userID = 99); Assuming you have MySQL 4.1 that is (which supports subselects). Regards, Mike Hillyer www.vbmysql.com > -----Original Message----- > From: Tim Winters [mailto:[EMAIL PROTECTED] > Sent: Wednesday, July 02, 2003 10:56 AM > To: [EMAIL PROTECTED] > Subject: Newbie SELECT problem > > > Hello everyone, > > I have the following select statement > > SELECT DISTINCT sessionID, userID, date, time > FROM sti_tracking > WHERE userID = 999 > > What I want is to have only records with the userID of 99 and > where the > sessionID is distinct (meaning only on of each session id). Neither > sessionID nor userID are keys or unique. > > Obviously this isn't working. > > Can someone suggest how this should be done? > > Tim Winters > Creative Development Manager > Sampling Technologies Incorporated > > 1600 Bedford Highway, Suite 212 > Bedford, Nova Scotia > B4A 1E8 > www.samplingtechnologies.com > [EMAIL PROTECTED] > [EMAIL PROTECTED] > Office: 902 450 5500 > Cell: 902 430 8498 > Fax:: 902 484 7115 > > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]