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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:28:38+00:00 2026-06-10T04:28:38+00:00

There are 3 DB tables involved. Players P1 P2 P3 P4 P5 ….. Team

  • 0

There are 3 DB tables involved.

Players

P1
P2
P3
P4
P5
.....

Team

T1
T2
T3
T4
T5
....

Player_Team

T1     P1
T1     P2
T1     P3
T1     P4
T2     P1
T2     P2
T2     P3
......

take into account the multiple combinations of no. of players. Also, a player can be in multiple teams

Ex. (P1 P2 P3 P4), (P1 P2 P3), (P1 P2), (P1 P3), (P2 P3) .. so on

In my app, I get a set of players playing in a particular match as a team. Given this set, i want to find the common team they belong to. Even if they are in multiple teams, the team containing only this set of players will be unique. So in above example, there is only one team which has players P1 P2 P3 and P4. But if the team has only 3 players P1 P2 P3, then we have more than one common team. Because, we might have combinations T1(P1 P2 P3 P4) T2(P1 P2 P3). Of course, we should not count T1 since it has P4, but exactly how should we do that?

So can you suggest a way (SQL query or program logic) to do this easy and efficiently?
Is there any sql function to get common team name (i.e. T2) ?

Any help is greatly appreciated ?

  • 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-10T04:28:40+00:00Added an answer on June 10, 2026 at 4:28 am

    You should use this query where 4 in this example is a count of players in set (P1,P2,P3,P4). If all Players in this team then for this TeamId count(PlayerID) = count of all players in the set:

    select teamId 
    from Player_Team 
    where PlayerId in (P1_Id,P2_ID,P3_ID,P4_ID)
    group by  teamId
    having count(PlayerId) = 4
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are 2 tables involved in this question: Table1: |- Time Stamp -|- Special
There are two databases and 4 tables involved in this query. The first database(PhoneBills)
I have this query below. There are 4 main tables involved: tblOrder, tblItems, tblOrder_archive,
I have EF 4 implemented in the project. Within it, there are tables customer
There are two tables Table 1 select * from manage_tcp; +----+----------+--------+ | id |
There are two tables: CREATE TABLE STORE ( ID INTEGER NOT NULL, MEDICINE_ID INTEGER
There are two tables Table A id column_a 01 abc 01 abc 02 abc
there are two tables tbldoctor and tblschedule tbldoctor doc_id(PK) docMrId docfname 1 22 manish
There are two tables: A, with rows (row_id, column1, ...) and B, with rows
There are three tables in my database: apples, refrigerators, and houses. Each apple belongs

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.