taith Posted December 13, 2006 Share Posted December 13, 2006 when i take the id out, it works perfectly, but i need both of those columns, i need distinct path, and all id's associated with it.[code]$result=mysql_query("SELECT DISTINCT path, id FROM im_files WHERE (`uid1`='$id' AND `uid2`='$key') OR (`uid2`='$id' AND `uid1`='$key') ORDER BY id") or die(mysql_error());[/code] Quote Link to comment Share on other sites More sharing options...
Round Posted December 13, 2006 Share Posted December 13, 2006 i'm assuming that as you are using distinct on path you are only retrieving 1 corresponding id record? Quote Link to comment Share on other sites More sharing options...
taith Posted December 13, 2006 Author Share Posted December 13, 2006 exactly, when i use distinct with path alone, it gives me one record... when i use it with id, it gives me all of them. Quote Link to comment Share on other sites More sharing options...
Round Posted December 13, 2006 Share Posted December 13, 2006 I might be wrong but when you use distinct in this context should you not use group by too?$result=mysql_query("SELECT DISTINCT path, id FROM im_files WHERE (`uid1`='$id' AND `uid2`='$key') OR (`uid2`='$id' AND `uid1`='$key') group by path") or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
taith Posted December 13, 2006 Author Share Posted December 13, 2006 perfect :-) thanks :-D 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.