Jump to content

db query question


ifm1989

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.