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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:32:35+00:00 2026-05-26T12:32:35+00:00

New to MySQL, so please bear with me. I’m working on a project that

  • 0

New to MySQL, so please bear with me.

I’m working on a project that collects user’s degrees. Users can save 3 degrees where the type, subject matter, and school are variable. These relations are normalized for other query uses so 5 tables are involved and are shown below (all have more columns then shown, just included the relevant info). The last one, ‘user_degrees’ is where the keys come together.

degrees

+----+-------------------+
| id | degree_type       |
+----+-------------------+
| 01 | Bachelor's Degree |
| 02 | Master's Degree   |
| 03 | Ph.D.             |
| 04 | J.D.              |
+----+-------------------+

acad_category

+------+-----------------------------------------+
| id   | acad_cat_name                           | 
+------+-----------------------------------------+
| 0015 | Accounting                              |
| 0026 | Business Law                            |
| 0027 | Finance                                 |
| 0028 | Hotel & Restaurant Management           |
| 0029 | Human Resources                         |
| 0030 | Information Systems and Technology      |
+------+-----------------------------------------+

institutions

+--------+--------------------------------------------+
| id     | inst_name                                  |
+--------+--------------------------------------------+
| 000001 | A T Still University of Health Sciences    |
| 000002 | Abilene Christian University               |
| 000003 | Abraham Baldwin Agricultural College       |
+------+----------------------------------------------+

users

+----------+----------+
| id       | username |
+----------+----------+
| 00000013 | Test1    |
| 00000018 | Test2    |
| 00000023 | Test3    |
+----------+----------+

user_degrees

+---------+-----------+---------+---------+
| user_id | degree_id | acad_id | inst_id |
+---------+-----------+---------+---------+
|      18 |         1 |       4 |       1 |
|      23 |         1 |      15 |       1 |
|      23 |         2 |      15 |       1 |
|      23 |         3 |      15 |       1 |
+---------+-----------+---------+---------+

How can I query ‘user_degrees’ to find all degrees by user x, but return the actual values of the foreign keys? Taking user Test3 as an example, I’m looking for output like so (truncated for layout’s sake):

+-------------------+-------------------+-------------------+
| degree_type       | acad_cat_name     | inst_name         |
+-------------------+-------------------+-------------------+
| Bachelor's Degree | Accounting        | A T Still Uni..   |
| Master's Degree   | Accounting        | A T Still Uni..   |            
| Ph.D.             | Accounting        | A T Still Uni..   |
+-------------------+-------------------+-------------------+

I’m guessing a mix of multiple joins, temp tables and subqueries are the answer but am having trouble grasping the order of things. Any insight is much appreciated, thanks for reading.

  • 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-26T12:32:36+00:00Added an answer on May 26, 2026 at 12:32 pm

    You need to join user_degrees to degrees (and the other tables referenced by user_degrees). This is the query that will give you your example output:

    SELECT
      ud.user_id, d.degree_type, ac.acad_cat_name, i.inst_name
    FROM
     user_degrees ud
     INNER JOIN degrees d ON d.id = ud.degree_id
     INNER JOIN acad_category ac ON ac.id = ud.acad_id
     INNER JOIN institutions i ON i.id = ud.inst_id
    WHERE
     ud.user_id = 18
    

    You may also want to read this article to understand different kinds of joins: http://www.codinghorror.com/blog/2007/10/a-visual-explanation-of-sql-joins.html

    The only way to understand these things at your stage of learning is to actually write the queries and then modify them until you get your desired output.

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

Sidebar

Related Questions

I am VERY new to mySQL, please bear with me. I have an array
Can we create a new MySQL database( not a table, I want a new
I am new to MySQL and PHP(as you can probably tell) and I was
I am fairly new to MySQL and have a project in which I need
I'm very new to MySQL and I have a stored procedure that I'd like
New to mysql and php, so forgive any obvious stupidity, please! One of mysql
My mysql installation is new and it was working a yesterday. Now, any MySQL
I'm new to PHP and MySQL. For my project I want to make a
I am fairly new to nHibernate and DDD, so please bear with me. I
I'm creating a new C# project. I want to connect it with the MySQL

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.