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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:37:10+00:00 2026-06-17T20:37:10+00:00

I have three tables, user , conversation , and conversation_participant with the rows: user

  • 0

I have three tables, user, conversation, and conversation_participant with the rows:

user
id

conversation
id
type

conversation_participant
conversation_id
user_id

(type indicates that it is a “private,” 1-1 conversation, i.e., ensuring that user1 and user2’s conversation is delineated from a group conversation involving, for example, user1, user2, and user3. type=0 is private, type=1 is a group.)

Regardless, how can I best structure a query that determines if a private conversation between two users (user_id=1 and user_id=2) exists? I am tempted to do something like this (I am very new to SQL, mind you):
SELECT conversation_participant.conversation_id FROM conversation_participant WHERE user_id=1 …but I’m pretty certain this is off to an unfortunate start.

What is the most concise way to manage a situation like this with queries from multiple tables that are all interconnected in this fashion? I assume it’s relatively simple, and if there are any good readings on this that you may know of, they would be much appreciated as well.

Thank you!

  • 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-17T20:37:12+00:00Added an answer on June 17, 2026 at 8:37 pm

    If I understand correctly that you are looking for conversations between two specific known user ids:

    select c.id
    from conversation_participant cp1
    inner join conversation_participant cp2
        on cp1.conversation_id=cp2.conversation_id and cp2.user_id=2
    inner join conversation c
        on cp1.conversation_id=c.id and c.type=0
    where cp1.user_id=1;
    

    In English, find ids of conversations where:

    user_id 1 is a participant (from and where clauses)

    and user_id 2 is a participant in the same conversation (first join clause)

    and that conversation is of private type (second join clause).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three tables that I am working with User, Application, ApplicationAdministrator. ApplicationAdministrator is
Suppose I have three tables: user , group and xref , a table that
I have three tables, a user-table and two user-type tables. The user-type tables have
I have three tables: User: UserId (pk) FirstName Lastname Messages: MessageId (pk) Heading Body
I have three tables which are defined as: class User(Base): __tablename__ = 'users' id
I have a conversation table, and a user conversation table. CONVERSATION Id, Subject, Type
I have three tables: user(id, name); tasks(id, user_id, text, date); bonus(id, user_id, sum, date,
Say I have three tables: User Table { UserId INT, Username NVARCHAR ... }
I have three tables (admin,domain,user) as shown below 'admin'(admin_id, email, domain_id, pass) 'domain'(domain_id, name)
I have three tables [USER] --Master user table [KEYWORD] --Master keyword table [USER_KEYWORD] --[USER]-[KEYWORD]

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.