graham23s Posted December 2, 2007 Share Posted December 2, 2007 Hi Guys, i have this query to select disctinct, user id's from mysql, but i have now realised i also need the `date` field assosciated with those fields: <?php $queryvisitors = "SELECT DISTINCT `visitorsid` FROM `usersvisitors` WHERE `usersid`='$var_loggedinuserid' ORDER BY `date` DESC LIMIT 5"; ?> is there away i can select the `date` field in the same query as distinct at all? thanks guys Graham Quote Link to comment Share on other sites More sharing options...
Barand Posted December 2, 2007 Share Posted December 2, 2007 if you want the date last visited by each visitor SELECT visitorsid, MAX(date) as lastvisit FROM uservisitors WHERE `usersid`='$var_loggedinuserid' GROUP BY visitorsid ORDER BY lastvisit DESC LIMIT 5 Quote Link to comment Share on other sites More sharing options...
graham23s Posted December 2, 2007 Author Share Posted December 2, 2007 Thanks barry i was way off lol. Graham Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.