ifm1989 Posted November 25, 2007 Share Posted November 25, 2007 I'm constructing a new private message system for my website. It's rather simple, but I just can't get one thing working. First, some info on the db tables: messages - Contains every post in every 'conversation', similar to how gmail groups messages. Columns include 'post_id', 'convo_id', 'message', and 'date' messages_users - Contains informations on users in each conversation. Columns include 'user_id', 'convo_id', and 'status' (read, or unread). I have this querry to pull messages for the inbox. This groups everything perfectly, however it lacks just one thing. I want it to be able to ALSO grab the user_id's of the other members in each conversation. here is the query: $result = dbquery("SELECT messages.convo_id AS convo_id,max(date) as date,count(messages.post_id) AS posts FROM messages LEFT JOIN messages_users ON messages_users.convo_id = messages.convo_id WHERE messages_users.user_id='".$userdata['user_id']."' GROUP BY messages_users.convo_id"); Thanks in advance! EDIT: Shit, I just realized I posted this in PHP help and not MYSQL help. Sorry :-\ Link to comment https://forums.phpfreaks.com/topic/78732-db-query-question/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.