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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:19:36+00:00 2026-06-16T00:19:36+00:00

I have three tables, each have a foreign key. When I perform a join,

  • 0

I have three tables, each have a foreign key. When I perform a join, I get duplicate columns.

Given

mysql> describe Family;
+---------------+-------------+------+-----+---------+-------+
| Field         | Type        | Null | Key | Default | Extra |
+---------------+-------------+------+-----+---------+-------+
| HEAD_name     | varchar(45) | NO   | PRI |         |       |
| Family_Size   | int(11)     | NO   |     |         |       |
| Gender        | char(1)     | NO   |     |         |       |
| ID_Number     | int(11)     | NO   |     |         |       |
| DOB           | date        | NO   |     |         |       |
| Supervisor_ID | int(11)     | NO   | MUL |         |       |
+---------------+-------------+------+-----+---------+-------+
6 rows in set (0.00 sec)

mysql> describe SUPERVISOR;
+-------------------+---------------+------+-----+---------+-------+
| Field             | Type          | Null | Key | Default | Extra |
+-------------------+---------------+------+-----+---------+-------+
| Supervisor_ID     | int(11)       | NO   | PRI |         |       |
| Supervisor_Name   | varchar(45)   | NO   |     |         |       |
| Supervisor_Number | decimal(10,0) | NO   |     |         |       |
| Center_ID         | int(11)       | NO   | MUL |         |       |
+-------------------+---------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

mysql> describe CENTER;
+-----------+-------------+------+-----+---------+-------+
| Field     | Type        | Null | Key | Default | Extra |
+-----------+-------------+------+-----+---------+-------+
| Center_ID | int(11)     | NO   | PRI |         |       |
| Location  | varchar(45) | NO   |     |         |       |
+-----------+-------------+------+-----+---------+-------+
2 rows in set (0.00 sec)

My query statement:

SELECT * from Family
   JOIN SUPERVISOR on ( Family.Supervisor_ID = SUPERVISOR.Supervisor_ID)
   JOIN CENTER on (SUPERVISOR.Center_ID = CENTER.Center_ID); 

My objective is to get one row of all the columns from the join without duplicate columns.
So what is the SQL statement syntax that I should use?

  • 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-16T00:19:36+00:00Added an answer on June 16, 2026 at 12:19 am

    By default MySQL will return all columns for all tables if you use *. You will need to explicitly enter column names in your query to retrieve them the way you want. Use the query as follows:

    SELECT A.HEAD_name, A.Family_Size, A.Gender, A.ID_Number, A.DOB,
        B.Supervisor_ID, B.Supervisor_Name, B.Supervisor_Number,
        C.Center_ID, C.Location
    FROM Family A
    JOIN SUPERVISOR B on ( A.Supervisor_ID = B.Supervisor_ID)
    JOIN CENTER C on (B.Center_ID = C.Center_ID);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three tables. Categories, topics, and posts. Each topic has a foreign key
I have three tables with 5 columns each. They can grow upto 15 rows
I have three tables: Type --------------------- TypeID (primary key) ParentTypeID (foreign key) TypeDescription (...)
I have a MySQL Left Join problem. I have three tables which I'm trying
I have a union of three tables (t1, t2, t3). Each rerun exactly the
I have a table that has three different date columns, so I set each
I have three tables in a MySQL database used in a music library application:
I'm trying to model which countries border each other in MySQL. I have three
Here's some background info. I have three MySQL tables (all InnoDB). The first table
I have two tables (notes and tags). Tags has a foreign key to notes.

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.