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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:49:20+00:00 2026-06-05T16:49:20+00:00

I have three tables (individuals, groups & recordlabels) and want use the information between

  • 0

I have three tables (individuals, groups & recordlabels) and want use the information between them to make a listing of people within the record label. Example: It should find the individuals and groups with the companyID of # and list them. How do I create this correctly without duplicates of the results?

// Connect to database
include "mysqli_connect.php";

// Set variables
$url_num = $_GET['company_id'];
$company_num = "";
$company_members = "";
$company_members2 = "";

//Check for artist id pagination
if(is_numeric($url_num)){
    $company = intval($url_num);
}else{
    $company = 1;
}

// Construct our join query
$sqli = "SELECT DISTINCT * FROM recordlabels
INNER JOIN individuals ON individuals.companyID=recordlabels.companyID
INNER JOIN groups ON groups.companyID=recordlabels.companyID
WHERE recordlabels.companyID = '{$company}'";

// Create results
$result = mysqli_query($link, $sqli);

//Check for albums
$totalmembers = mysqli_num_rows($result);

// Checking if query is successful
if($result){

// Print out the contents of each row into a table 
while($row = mysqli_fetch_array($result, MYSQLI_BOTH)){

// Assign value of column if not empty, otherwise "DamJuNoImage" (Thanks to Jonathan Sampson from Stack Overflow)
    $companyen = empty( $row["companyen"] ) 
        ? "Unknown" 
        : $row["companyen"];
    $companyko = empty( $row["companyko"] ) 
        ? "Unknown" 
        : $row["companyko"];
    $companyType = empty( $row["companyType"] ) 
        ? "Unknown" 
        : $row["companyType"];
    $founded = empty( $row["established"] ) 
        ? "Unknown" 
        : $row["established"];
    $founder = empty( $row["companyFounder"] ) 
        ? "Unknown" 
        : $row["companyFounder"];
    $information = empty( $row["information"] ) 
        ? "Unknown" 
        : $row["information"];
    $location = empty( $row["companyLocation"] ) 
        ? "Unknown" 
        : $row["companyLocation"];
    $homepage = empty( $row["companyPage"] ) 
        ? "#" 
        : $row["homepage"];
    $solopic = empty( $row["solopic"] ) 
        ? "DamjuNoImage" 
        : $row["solopic"];
    $soloen = empty( $row["soloen"] )
        ? "Unknown"
        : $row["soloen"];
    $solokn = empty( $row["solokn"] )
        ? "Unknown"
        : $row["solokn"];
    $grouppic = empty( $row["grouppic"] ) 
        ? "DamjuNoImage" 
        : $row["grouppic"];
    $groupen = empty( $row["groupen"] )
        ? "Unknown"
        : $row["groupen"];
    $groupkn = empty( $row["groupkn"] )
        ? "Unknown"
        : $row["groupkn"];
    $company_members .= '<li><a href="#">
      <div class="image"><img src="pathhere/' . $solopic . '"></div>
      <p class="datatitle2">' . $soloen . '</p>
      <p class="data-info2">' . $solokn . '</p>
      </a></li>';
    $company_members2 .= '<li><a href="#">
      <div class="image"><img src="pathhere' . $grouppic . '"></div>
      <p class="datatitle2">' . $groupen . '</p>
      <p class="data-info2">' . $groupkn . '</p>
      </a></li>';
    $listofmembers = $company_members . $company_members2; 
} // End of while statement
}else{
    echo "No people under $companyen";
} // End of If statement

To give a (hopefully) better visual.

  • Bob (individuals)
  • Lisa (individuals)
  • Mania (groups)

My testing before seeking help gave this result:

  • Bob (individuals)
  • Lisa (individuals)
  • Mania (groups)
  • Mania (groups)

That was because I put the output of individuals and groups in their own separate value. Then I echoed $var1 . $var2 which I felt would go wrong.

UPDATE: If nobody can figure it out, I’ll just redo my database and tables. Thank you all you tried to help.

  • 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-05T16:49:23+00:00Added an answer on June 5, 2026 at 4:49 pm

    The issue is most likely coming from your SQL code. Specifically, you appear to have some denormalization, with companyId in both individual and group, and individual having a groupId foreign key.

    Given this relationship, you most probably want to write your statement along these lines:

    SELECT companyEn, companyKo, companyType, established, companyFounder, 
           information, companyLocation, companyPage,
           soloPic, soloEn, soloKn, 
           groupPic, groupEn, groupKn
    FROM recordLabels
    JOIN groups 
    ON groups.companyId = recordLabels.companyId
    JOIN individuals
    ON individuals.groupId = groups.groupId
    WHERE recordLabels.companyId = $company
    

    Other minor notes:
    From what I’ve heard, best practice usually gives tables singular names, not plural ones.
    What’s up with the ....En and ...Ko columns? It seems to me like you may be doing some internationalization (English and Korean?) – if so, you’re going to want to extract those columns out of the original tables, and start translation tables. This will aid you greatly if you need to add support for additional languages later.


    EDIT:

    Although there’s multiple ways to handle translation tables, you probably want one translation table per table that needs translated data. You’ll also probably want a standard language table for reference:

    language
    ============
    id  -- autoincrement - or possibly just use code
    code  -- ISO 3-letter code, unique
    shortCode  -- ISO 2-letter code, unique (I think?)
    name  -- ISO standard name
    

    Taking recordLabel as an example:

    1) Create your translated table, with all columns that will need to be translated:

    recordLabelTranslation
    =====================
    companyId  -- fk to recordLabel.companyId, or whatever the primary key of that table is
    languageId  -- fk to language.id
    company  -- whatever 'companyEn' and 'companyKo' was (company name?  why translate?)
    

    2) Remove all columns that were translated (companyEn, companyKo)

    3) (optional) code up a view so you have an easy reference. There are two flavours:

    -> simple join for language

    CREATE VIEW Record_Label_Language as 
    SELECT recordLabel.companyId, recordLabel.information, -- all current columns...
           recordLabelTranslation.languageId, recordLabelTranslation.company
    FROM recordLabel
    JOIN recordLabelTranslation
    ON recordLabelTranslation.companyId = recordLabel.companyid
    

    -> join for language, with default to english (or some other language)

    CREATE VIEW Record_Label_Language_Default as 
    SELECT recordLabel.companyId, recordLabel.information, -- all current columns...
           COALESCE(recordLabelTranslation.languageId, language.languageId),
           COALESCE(recordLabelTranslation.company, dflt.company)
    FROM recordLabel
    JOIN recordLabelTranslation as dflt
    ON dflt.companyId = recordLabel.companyid
    AND dflt.languageId = [englishLanguageId]
    CROSS JOIN language
    LEFT JOIN recordLabelTranslation
    ON recordLabelTranslation.companyId = recordLabel.companyId
    AND recordLabelTranslation.languageId = language.id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Preface I have three tables Customers, Individuals & Companies and a customer can be
I have three tables of information where the business_id is the common thread. I
I have three tables specifying important columns below Users(Id, username) Groups(Id, groupname, creator) (creator
I have three MySQL InnoDB tables: Debtors Companies Private individuals Now I would like
I have three tables. Let's call them a, b, and a_to_b. a_to_b contains (among
I have three tables, one listing contacts, the other users, and the last emails.
I have three tables A: A.pID primary key, A.Name nvarchar(250) B: B.pID primary key,
I have three tables: videos, videos_categories, and categories. The tables look like this: videos:
I have three tables being used for this problem: songs, blacklist, and whitelist. The
I have three tables: User: UserId (pk) FirstName Lastname Messages: MessageId (pk) Heading Body

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.