Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7072303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:47:33+00:00 2026-05-28T05:47:33+00:00

Am creating a messaging system model after facebook’s messages. The message inbox is threaded,

  • 0

Am creating a messaging system model after facebook’s messages.
The message inbox is threaded, but am having issues with my query for viewing for a message and other messages exchanged in thread.
db tables look like this.

messages

  • mid
  • seq
  • created_on
  • created_by
  • body

messag_recips

  • mid
  • seq
  • uid
  • status

Note: the MID column is the message ID. Think of each initial message as the beginning of a thread. Instead of having unique message IDs that are all parent/children, I decided to have one main thread (MID) and then have messages in it – which are all defined by the SEQ (sequence number) column. The rest is pretty self explanatory. The created_by and all subsequent user identifications will be numeric ID’s that may point to a different user ID somewhere else. The last thing to note is that the primary key is based on the MID and the SEQ – you will never have more than one entry per MID/SEQ.
STATUS column – which will be N for new, A for active (or read) and D for deleted

this is my query

$sql = "select m.mid, m.seq, m.created_on, m.created_by, m.body, r.status from message_recips r
                inner join messages m on m.mid=r.mid and m.seq=r.seq
                where r.uid='$uid' and m.mid='$mid' and r.status in ('A', 'N')";

but it returns only messages sent to the current user, i want it to return message also sent by the current user. How should i modify the query?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:47:33+00:00Added an answer on May 28, 2026 at 5:47 am

    It seems like you are trying to get both messages sent to the current user, as well as messages sent by the current user… an OR relationship.

    Try this:

    where (r.uid='$uid' OR m.created_by='$uid') and m.mid='$mid' and r.status in ('A', 'N')";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a messaging system but the problem I face is that when
I'm creating a messaging system for use in an XNA game. My Message types
I'm creating a messaging web app in ASP.NET and are having some problems when
I'm creating a messaging system (using PHP) and want to assign an ID number
I'm creating a messaging system and I'm trying to set it up so it
I'm currently working on creating a private messaging system, (PHP/MySQL) in which users can
im creating a messaging feature that gets the latest messages from a database every
i am Creating messaging system in asp.net. how can i call client on database
I'm creating interfaces and abstract classes that represent a messaging framework for short text-based
(creating a separate question after comments on this: Javascript redeclared global variable overrides old

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.