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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:49:53+00:00 2026-05-20T01:49:53+00:00

Assume that we have two data sets A, B that have m to n

  • 0

Assume that we have two data sets A, B that have m to n relationship.

A = { k1, k2, k3 …. kn}
B = { g1, g2, g3……….gn}

All the elements in both the sets are alphanumeric.
Now, tuples one each from Set A and Set B are stored in a table T.

for ex :-
(k1, g2)
(k2, g4)
(k1, g3)
(k4, g2)
…
…
..
(kn, gm)

The challenge is to find out what ‘m’ elements in set A map to what ‘n’ elements in set B in the most efficient way.

For ex, let’s say we have the below tuples,

(k1, g1)
(k1, g2)
(k3, g1)
(k3, g2)
(k5, g1)
(k5, g2)

the o/p I need is (k1, k3, k5) -> (g1, g2).

As the mapping is m to n, a simple select won’ t work. Please let me know if you need further clarifications

Since this information is already in database, I would prefer if we can get to this with some SQL.

Help much appreciated.

Thanks in advance…

  • 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-20T01:49:53+00:00Added an answer on May 20, 2026 at 1:49 am

    You can often solve problems like this by using an aggregate, and a group by clause.

    For example, if your table name is T then:

    select T.item1, concat(T.item2, ", ") from T group by T.item1
    

    Gives you which item1 maps to item 2. THen do it again switching item1 and item 2 around to find which item2 maps to item1.

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

Sidebar

Related Questions

To illustrate, assume that I have two tables as follows: VehicleID Name 1 Chuck
I have a form that has two buttons. One for saving a record and
Assume that we have N erlang nodes, running same application. I want to share
Assume that you have a running SQL Server Express instance named (local)\SQLEXPRESS. Its database
I'm working on an assignment that is telling me to assume that I have
Let's assume I have a model called product. Let's assume that product has three
Assume I have an ASP.NET MVC app that's not doing anything too fancy (no
(code examples are python) Lets assume we have a list of percentages that add
Connection.close() may throw SqlException , but I have always assumed that it is safe
Assume that the core project has a base entity and every plugin maybe extends

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.