Jump to content

[SOLVED] query problems


EchoFool

Recommended Posts

Hey guys,

 

I have a query which is causing problems as the "group by" is not working. Not sure how to fix the problem though.

 

 

This is what i got:

 

$Get = mysql_query("SELECT * FROM msgs WHERE Sender='$ID' OR Receiver='$ID' GROUP BY Sender,Receiver ORDER BY Time")
Or die(mysql_error());

 

What is happening though is im getting two rows the reason why is because of this:

 

In the table theres 2 rows like this:

Sender      |      Receiver

  2                      99

  99                      2

 

 

This is why it comes out twice.. how do i merge it so it will only represent that as one not both? Because I am trying to get all users that $ID has spoke to "uniquely" so it should only show one row in the above case because $ID has spoke to ID 2 it doesn't need to tell me twice... hope you can help

 

Link to comment
https://forums.phpfreaks.com/topic/88905-solved-query-problems/
Share on other sites

what exactly is the goal of this query to retrieve a message?

 

If so it should have a message ID to query from and not this sender/receive combo

 

 

If you want all messages between two people simply say get all mesages were person A is the sender and Person B is the sender and then where person B was recieve of or person A

Link to comment
https://forums.phpfreaks.com/topic/88905-solved-query-problems/#findComment-455408
Share on other sites

No sorry i should have explained better. I am trying to get the ID of the other person that $ID has contacted.

 

For example:

ID = 4

 

So say the table has:

 

Sender | Receiver

 

  4            99

  3              4

  99            4

  3              2

  1              4

  4              45

 

The result from my query should show....

The users ID 4 has received or sent a message from/to are:

99

3

1

45

 

 

Link to comment
https://forums.phpfreaks.com/topic/88905-solved-query-problems/#findComment-455634
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.