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 8229079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:40:46+00:00 2026-06-07T16:40:46+00:00

I have an implementation messages system. My problem is, I would like to know

  • 0

I have an implementation messages system.
My problem is, I would like to know whether a user already has a thread with another user and if so what is the mid

I have a messages_recips table which look like this

---------------------------     
| mid | seq | uid | status|
|--------------------------
| 4   | 1   | 1   | A     |
| 4   | 1   | 2   | A     |
---------------------------

if user id 1 having a thread with user id 2 I hold 2 rows with same mid.
I know I can create 2 sqls to achieve what I’m asking for, but I’m trying to do it in 1 sql.

  • 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-06-07T16:40:48+00:00Added an answer on June 7, 2026 at 4:40 pm

    I think you have to write a self-join query:

    Select u.uid, u1.uid from tablename u
     INNER JOIN tablename u1 on u.mid = u1.mid
    

    You will get all the users who have the same mid.

    In order to get only user1 and user2 records you have to place a where clause at the end of the query lik this.

     Select u.uid, u1.uid from tablename u
     INNER JOIN tablename u1 on u.mid = u1.mid
     Where ( u.uid In ( 1,2 ) OR u1.uid In ( 1,2 ) ) ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a questions regarding implementation of a system that will send messages to
I don't know either my implementation have bugs or StringBuilder is going wrong. From
I know that it's OK for a pure virtual function to have an implementation.
I'm in a situation where another system in my domain is sending SOAP messages
This is kind of a beginner question. For now I have the implementation like
I have something like Message forwarder / router for MQ messages. I'm trying to
I downloaded the JSON2.js from https://github.com/douglascrockford/JSON-js/blob/master/json2.js and it does not have implementation for JSON2.stringify()
I have an implementation of lazyDataModel following this tutorial http://uaihebert.com/?p=1120 My code its a
I have an implementation of a DefaultTableCellRenderer. When someone selects a row in the
I have STI implementation as follows: class Automobile < ActiveRecord::Base end class Car <

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.