WmZilla - Webmaster and Marketplace

The Next Generation Webmaster and Trade Forum

I am stuck on the usage of "Mysql group by and join" in the chatbox.

Chrism13

New member

0

0%

Status

Offline

Posts

42

Likes

0

Rep

0

Bits

220

3

Months of Service

0%
Hello, I'm trying to create a chatbox where messages are listed in groups. I'm fetching messages in MySQL queries both sent and received, but there's a missing point, it's not working as it should. I have a table called "uyeler" which stores members in the format of uyeler > uye_id > uye_adi, and I have a table to store messages in the format of om > om_id > om_gonderen_id > om_alici_id > om_mesaj> om_tarih. Here is the MySQL query I'm using: When I change GROUP BY om.om_tarih to GROUP BY uyeler.uye_id, it works properly, but only 2 rows are coming, not all messages. Here is the query: SELECT * FROM om JOIN uyeler ON uyeler.uye_id = om.om_alici_id OR uyeler.uye_id = om.om_gonderen_id WHERE om.om_gonderen_id = ".$sender_id." OR om.om_alici_id = ".$recipient_id." OR om.om_alici_id = ".$sender_id." OR om.om_gonderen_id = ".$recipient_id." GROUP BY om.om_tarih This way, all messages are listed as I want, but when looping through the messages, only the name of om.om_alici_id comes as uye_adi. I realize that I'm running a wrong query, and if anyone who knows can help, I would appreciate it. In other words, what I mean is that all names are the same, whether it's incoming or outgoing messages. Like this;
 

249

6,622

6,642

Top