Jump to content

mysql distinct error


taith

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.