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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:04:47+00:00 2026-06-05T04:04:47+00:00

Sorry if the title to this post is a bit confusing. My question is

  • 0

Sorry if the title to this post is a bit confusing. My question is rather simple and I know the solution has to do with a join, but I can’t exactly figure out the related posts.

I’m putting together a class schedule in MySQL and the classes have prerequisites. In order to do this, I have 1 table with all of the classes available (ClassName), and, of course, a primary ID (Class_ID). I then have another table of classes offered this semester, built using the information from the “classes available” table. This table starts with a unique id (ClassSemester_ID), Class_ID, and a Prerec_ID for the class’s prerequisite. The Prerec_ID is actually the Class_ID of a different class.

This means that on an actual schedule, I need to the ClassName Column to match up with both Class_ID and Prerec_ID. More visually:

Table 1: AllClasses
Col1: Class_ID
Col2: ClassName

Table 2: SemesterClasses
Col1: ClassSemester_ID
Col2: Class_ID
Col3: Prerec_ID

How do I construct a query that will output both Class_ID and Prerec_ID showing their associated ClassName?

Thanks in advance guys!

-CB

  • 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-05T04:04:48+00:00Added an answer on June 5, 2026 at 4:04 am

    i believe it would be more efficient as

    select SemesterClasses.Class_ID, AllClasses.ClassName, PreRequisite.ClassName as PreRequisiteName
    from SemesterClasses
    left join AllClasses on AllClasses.Class_ID = SemesterClasses.Class_ID
    left join AllClasses as PreRequisite on PreRequisite.Class_ID = SemesterClasses.Prerec_ID
    

    Should return all SemesterClasses rows with the class id, name and pre-requisite name.
    One could also add columns in the semesterclasses for the year and such and apply the filters on the where.

    Hope it helps

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

Sidebar

Related Questions

I'm sorry if the title is a bit confusing, but this is my problem:
Sorry but I dont know what title I should give this question(Suggestion?) I have
Sorry if the title sounds confusing - but this is what I am trying
Sorry for the unhelpful title, but hopefully I can explain this well enough. Lets
I am sorry about the title of this post, but I've no idea how
Sorry for the stupid title, but I don't know how else to name this
Sorry for the bad title, but I don't know how to name this. My
Sorry about the vague title, but I really don't know how to describe this
Sorry if this is a stupid question, but I can't get this to work.
I'm sorry for ambiguous title, but this question is hard for me to put

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.