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 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

Assume that we have two sets: A=(a_1,a_2,...,a_m) and B=(b_1,b_2,...,a_n) (Not necessarily of same size).
I have a city table that has two columns from_city to_city now lets assume
Say I have two sets of data, each entry consisting of a weight. Each
Assume that I have two arrays as follow: $array1 = array(1, 3, 5); $array2
Let's say we have two objects. Furthermore, let's assume that they really have no
Let's assume I have two gmdistibution models that i obtained using modeldata1=gmdistribution.fit(data1,1); modeldata2=gmdistribution.fit(data2,1); Now
Assume that I have some array of data (a vector to be specific). Can
I have two tables say ( FCT_SALES_SUMMARY_A and FCT_SALES_SUMMARY_B ). If we assume that
I have two MySQL database tables that are meant to hold data for eshop
Let's assume that I have two tables... Foo and Bar. They contain the following

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.