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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:54:55+00:00 2026-06-11T05:54:55+00:00

I have such a hard time picturing this. I just don’t have the brain

  • 0

I have such a hard time picturing this. I just don’t have the brain to do it.

I have a table called reports.

---------------------------------------------
| report_id   | set_of_bads | field1 | field2 |
---------------------------------------------
| 123         | set1        | qwe    | qwe    |
---------------------------------------------
| 321         | 123112      | ewq    | ewq    |
---------------------------------------------

I have another table called bads. This table contains a list of bad data.

-------------------------------------
| bad_id    | set_it_belongs_to | field2 | field3  |
-------------------------------------
| 1         | set1              | qwe    | qwe     |
-------------------------------------
| 2         | set1              | qee    | tte     |
-------------------------------------
| 3         | set1              | q44w   | 3qwe    |
-------------------------------------
| 4         | 234               | qoow   | 3qwe    |
-------------------------------------

I want to setup a primary key to foreign key relationship. My question is, how do I connect the field set_of_bads to set_it_belongs_to in the bads table. This way if I want to get the entire set of data that is set1 by calling on the reports table I can do it.

Example: hey reports table.. bring up the row that has the report_id 123. Okay thank you.. Now get all the rows from bads that has the set_of_bads value from the row with the report_id 123, in set_it_belongs_to field. Thanks.

  • 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-11T05:54:57+00:00Added an answer on June 11, 2026 at 5:54 am

    try this one,

    SELECT  a.*,      -- will display all records from reports table
            b.*       -- will display all records from bads table
    FROM    reports a
            INNER JOIN bads b
                ON a.set_of_bads = b.set_it_belongs_to
    WHERE   a.report_ID = 123
    

    Update 1

    In your CREATE TABLE statement, specify a foreign key constraint on bads table

    CREATE TABLE bads
    (
    bad_id INT AUTO_INCREMENT   ,
     set_it_belongs_to VARCHAR(50),
     field2 VARCHAR(50),
     field3 VARCHAR(50),
     CONSTRAINT bads_pk PRIMARY KEY (bad_id),
     CONSTRAINT bads_fk FOREIGN KEY (set_it_belongs_to) 
        REFERENCES reports(set_of_bads)
    );
    

    and make sure that the primary key of reports table is set_of_bads

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

Sidebar

Related Questions

Hey guys I'm having such a hard time of it today. I have a
I'm having a really hard time finding an answer for this, with such generic
This seems like such a simple task, but I'm having a hard time finding
I've just started learning C and I have a hard time finding bugs, memory
I'm having a hard time phrasing this question in such a way that doesn't
Should not be such a hard question... I'm just having a hard time figuring
have such zend query: $select = $this->_table ->select() ->where('title LIKE ?', '%'.$searchWord.'%') ->where('description LIKE
I'm a developer, and I find that I have a hard time dealing with
I'm having a hard time describing this problem. Maybe that's why I'm having a
I'm having a hard time figuring this problem out - I am trying to

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.