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

  • Home
  • SEARCH
  • 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 7523005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:40:19+00:00 2026-05-30T02:40:19+00:00

Scenario: many to many relationships. table has 2 columns: UserID and UserChoiche I am

  • 0

Scenario: many to many relationships.

table has 2 columns: UserID and UserChoiche

I am storing the user preferences one by one in each row.
(Is this the most efficient way?)

Example:

UserID         UserChoiche

mark                             anna
mark                             paul
mark                             john
john                             mark

In this example mark chose 3 users, and john chose 1 user.

John and Mark have chosen each other and I need php to find this db relationship.

//php mysql query that selects all the choiches of a specified user (in this case mark)
SELECT UserChoiche from exampletable WHERE UserID mark

//find the matches
??
here is my problem: I am looking for the easiest and most efficent way to handle this!

Maybe like this? (It could work but I cannot write a mysql statement, is too complicated for me!)
If Userchoice of previous query (in this case it would return anna paul and john) EQUALS any Userid in the table (in this case john) AND that Userid has a Userchoiche with the value of the UserID from the previous query (in this example 4th row)
then we have a match

//if matches found, then take the UserID and UserChoiche and store them into variables which I will use to make some notifications (there can be many matches, so maybe use an array?)

  • 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-30T02:40:20+00:00Added an answer on May 30, 2026 at 2:40 am
    SELECT t1.UserID, t2.UserID
    FROM table t1, table t2
    WHERE t1.UserID = t2.UserChoiche
       AND t2.UserID = t1.UserChoiche
    

    That should spit out the two that chose each other. We are basically joining the table to itself to find the mutual relationship

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

Sidebar

Related Questions

Obfuscated Scenario : A person has zero, one or many pets. Using Linq to
Here is the scenario: You have a Persons table with a one-to-many relationship with
There are many errors here in SO, but this scenario I think its different.
I have two tables, Table_A and Table_B. Table_A has a one-to-many relationship with Table_B.
I have the following scenario. I have one table in the database A that
Say we have this scenario: Artist ==< Album ==< Track //ie, One Artist can
I have this scenario I have four classes User profiles Activity Workbook user can
In my scenario I have a many to many relationship with single table. So
Example scenario: Two tables: order and orderItem , relationship One to Many. I want
I have a scenario where I need to search from many binary files (using

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.