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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:09:15+00:00 2026-05-14T00:09:15+00:00

I have a database two tables and a linking table that I need a

  • 0

I have a database two tables and a linking table that I need a JOIN query for:

Here are my Tables:

family (userid (int), loginName, etc)
member (memberid (int), loginName(this links member to a family),name, etc)

Linking Table:
user2member (userid,memberid)…would both be foreign keys?

I want to do two things:

1) Be able to have a family.loginName(12,Johnson) subscribe to another family.loginName (43,Smith) and record that into the linking table.

That would look like this:
12,43

2) When I do a query for all the member.name that are in the Johnson Family, I’ll get all the Johnsons & all the Smiths.

If Johnson = Ted, Sue & Patty
IF Smith =Joe, Sue & Bob

my query results would be Johnson now = Ted,Sue,Patty,Joe,Sue,Bob

I asked this question a few days ago without good table names and I ended up confusing myself and the nice guy Ollie Jones who posted an answer similar to this for the query:

SELECT member.name
 FROM family
   JOIN user2member on family.userid = member.memberid
   JOIN member on user2member.name = member.name
 WHERE family.userid = '30'
ORDER BY member.name

I had to change Ollie’s answer to match my tables but I’m getting a limit error 0,30 on line 5.

This is my first time doing JOINS and I have no idea if this is correct.

Thanks,

Here’s the link to my first question: mySQL table linking , group linked to other members lists, the displaying all members

  • 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-14T00:09:15+00:00Added an answer on May 14, 2026 at 12:09 am

    I am not sure, if the tables you suggested would solve your problem. If I understand your question correct, there are two relationships:

    • a relationship for all family members (Johnson with Ted, Sue, Patty, Smith with Joe, Sue, Bob)
    • a relationship for subscriptions (a family can subscribe to another family)

    I would suggest following tables:

    • family (f_id, f_loginName, etc.)
    • member (m_id, m_f_id, m_name) (foreign key to family, many-to-one relationship)
    • subscription (s_f_id,s_to_f_id) (linking is based on both family keys)

    This would result in following contents:

    family:
    f_id   f_loginName
    12     Johnson
    43     Smith
    
    member:
    m_id   m_f_id   m_name
    1      12       Ted
    2      12       Sue
    3      12       Patty
    4      43       Joe
    5      43       Sue
    6      43       Bob
    
    subscription
    s_f_id s_to_f_id
    12     43
    

    Now, to get all possible members for a specific family and it’s subscriptions, I would use following SQL query. It has a simple join for family and it’s family members. In the WHERE clause, the family Johnson is fetched (f_id = 12) and to get all family members from the subscriptions, it’s easier to use a subquery.

    SELECT f_loginName, m_name 
    FROM family
    INNER JOIN member ON m_f_id = f_id
    WHERE f_id = 12 
          OR f_id IN (SELECT s_to_f_id FROM subscription WHERE s_f_id = 12) 
    ORDER BY f_loginName, m_name;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 357k
  • Answers 357k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The other answers are correct. Here is some code you… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer you ruin the noConflict concept by reassigning the jquery to… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer If you get that particular error, you don't actually have… May 14, 2026 at 9:40 am

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.