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] Link to comment https://forums.phpfreaks.com/topic/30479-mysql-distinct-error/ 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? Link to comment https://forums.phpfreaks.com/topic/30479-mysql-distinct-error/#findComment-140330 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. Link to comment https://forums.phpfreaks.com/topic/30479-mysql-distinct-error/#findComment-140331 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()); Link to comment https://forums.phpfreaks.com/topic/30479-mysql-distinct-error/#findComment-140338 Share on other sites More sharing options...
taith Posted December 13, 2006 Author Share Posted December 13, 2006 perfect :-) thanks :-D Link to comment https://forums.phpfreaks.com/topic/30479-mysql-distinct-error/#findComment-140341 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.