thefollower Posted December 25, 2007 Share Posted December 25, 2007 I have a query which is meant to group the users that the person has contacted.. for example: Say i contacted user id 2 twice... in the list it will only show it as once. At the moment how ever it is displaying like this: Contacted Users: 2 2 Which is wrong. It should group 2 to become 1. Like so: Contacted Users: 2 This is what i got: <?php $GetConversation = mysql_query("SELECT *, IF(Sender='$ID', Receiver, Sender) as otherPartyID FROM messages UNION SELECT *, IF(Sender='$ID', Receiver, Sender) as otherPartyID FROM textmessages UNION SELECT *, IF(Sender='$ID', Receiver, Sender) as otherPartyID FROM phonecalls WHERE Sender='$ReportedPlayer' OR Receiver='$ReportedPlayer' GROUP BY otherPartyID ") or die(mysql_error()); ?> Quote Link to comment https://forums.phpfreaks.com/topic/83160-mysql-query-problem/ Share on other sites More sharing options...
Barand Posted December 25, 2007 Share Posted December 25, 2007 If this topic is "solved" in the PHP Help forum, why is it posted here, several hours later? Don't double post. Closing PHP Help topic Quote Link to comment https://forums.phpfreaks.com/topic/83160-mysql-query-problem/#findComment-423019 Share on other sites More sharing options...
thefollower Posted December 25, 2007 Author Share Posted December 25, 2007 Well if you read the post in PHP you will see its not solved cos no one replied.... How ever i pressed solved because staff did not move it.. so i pressed solved and re-posted here. Didn't know what else to do sorry. Quote Link to comment https://forums.phpfreaks.com/topic/83160-mysql-query-problem/#findComment-423042 Share on other sites More sharing options...
Gamic Posted December 25, 2007 Share Posted December 25, 2007 select [b]distinct [/b] rows from tables; If any two (or more) result rows have the same output then these *extra* rows will not be displayed. Quote Link to comment https://forums.phpfreaks.com/topic/83160-mysql-query-problem/#findComment-423053 Share on other sites More sharing options...
thefollower Posted December 25, 2007 Author Share Posted December 25, 2007 <?php $GetConversation = mysql_query("SELECT distinct rows *, IF(Sender='$ID', Receiver, Sender) as otherPartyID FROM messages UNION SELECT distinct rows *, IF(Sender='$ID', Receiver, Sender) as otherPartyID FROM textmessages UNION SELECT distinct rows *, IF(Sender='$ID', Receiver, Sender) as otherPartyID FROM phonecalls WHERE Sender='$ReportedPlayer' OR Receiver='$ReportedPlayer' GROUP BY otherPartyID ") or die(mysql_error()); ?> Like that? Quote Link to comment https://forums.phpfreaks.com/topic/83160-mysql-query-problem/#findComment-423078 Share on other sites More sharing options...
Gamic Posted December 26, 2007 Share Posted December 26, 2007 I think so, try it out and let us know if there are any problems with that. Quote Link to comment https://forums.phpfreaks.com/topic/83160-mysql-query-problem/#findComment-423114 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.