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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:14:35+00:00 2026-06-14T03:14:35+00:00

I currently have a database with 12 tables. I am doing a php query

  • 0

I currently have a database with 12 tables. I am doing a php query to pull the information from the database but I am not getting anything displayed. The query alone bridges all the tables starting with table schedule that have a foreign key related. Should I need to start the query from the table class and bridge with other tables?

TABLE DESIGN- PICTURE

If you like to duplicate my design- QUERY

$query = ("SELECT  class_name, class_caption, class_credit_hours, class_description
                FROM schedule 
                INNER JOIN section 
                ON class.id = section.class_id
                INNER JOIN faculty
                ON faculty.id = section.faculty_id
                INNER JOIN faculty
                ON faculty.id = office_hours.faculty_id
                INNER JOIN faculty_titles
                ON faculty_titles.faculty_id = faculty.id
                INNER JOIN faculty_education
                ON faculty_education.faculty_id = faculty.id 
                INNER JOIN section
                ON section.faculty_id = faculty.id 
                INNER JOIN class
                ON class.id = section.class_id
                INNER JOIN major_class_br
                ON major_class_br.class_id = class.id
                INNER JOIN  major_minor 
                ON major_class_br.major_minor_id = major_minor.id                
                 ");
      //execute query
      $result = mysql_query($query);

     if ($result){

    $totalhours = 0;

    while ($row = mysql_fetch_assoc( $result ))
    {  
        print "<b>" . $row['class_name'] . "</b><br>";
        print $row['class_caption'] . "<br>";
        print $row['class_description'] . "<br>";
        print $row ['class_credit_hours'] . "hrs. <br>";
        print "------------------------------<br />";
        $totalhours += $row['class_credit_hours']; 
    }   
    }

SQL fiddle query

  • 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-14T03:14:36+00:00Added an answer on June 14, 2026 at 3:14 am
    SELECT  class_name, class_caption, class_credit_hours, class_description
                 FROM schedule 
                INNER JOIN section 
                ON class.id = section.class_id
    

    Right here there’s a problem: you are doing a INNER JOIN using the field ‘class.id’ but the table ‘class’ isn’t in either side of the JOIN. So it won’t work.

    The query should start like this:

    SELECT  class_name, class_caption, class_credit_hours, class_description
                 FROM class
                INNER JOIN section 
                ON class.id = section.class_id
    

    And then do the JOIN with the table ‘schedule’ with the table it shares a common index (I guess it would be class).

    The complete query should be something like this:

    SELECT  class.class_name, class.class_caption, class.class_credit_hours, class.class_description
                FROM class
                INNER JOIN section 
                ON class.id = section.class_id
                INNER JOIN faculty 
                ON faculty.id = section.faculty_id OR faculty.id = office_hours.faculty_id
                INNER JOIN faculty_titles
                ON faculty_titles.faculty_id = faculty.id
                INNER JOIN faculty_education
                ON faculty_education.faculty_id = faculty.id 
                INNER JOIN major_class_br
                ON major_class_br.class_id = class.id
                INNER JOIN major_minor 
                ON major_class_br.major_minor_id = major_minor.id
                INNER JOIN sched_sect_br 
                ON sched_sect_br.section_id =  section.id
                INNER JOIN schedule
                ON schedule.id = sched_sect_br.schedule_id
                INNER JOIN semester
                ON semester.id = schedule.semester_id
                INNER JOIN office_hours
                ON schedule.id = office_hours.schedule_id AND faculty.id = office_hours.faculty_id
    

    This query gets info from all the tables you have in your graph, aside from the event table, that isn’t related to any other. But still this query should have more fields on the SELECT (you are only selection fields from the class table, I understand you’d want data from the other 10 tables as well), to do this simple add ‘tablename.field’ to the list of fields from the SELECT.

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

Sidebar

Related Questions

I currently have a bunch of SQLCHAR objects from a database query. The query
I'm making a php page to draw information from a mysql database, and before
I am worried I am not doing this correctly. Currently I have implemented a
We have 3 tables in the database: [Unapproved].[Data] [Approved].[Data] [History].[Data] We currently have 3
I currently have a very simple MySQL database (articlesDB) with 1 table (articles) and
I'm trying to normalize a mysql database.... I currently have a table that contains
Suppose I am building an app using current mysql database tables. I have this
We have this current database which we need to replace some tables by anther
Currently I have database with the following associations: One Client to Many Intakes One
Currently I have a database of Courses, and it has 6 columns: class Course(models.Model):

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.