SQL THAT CREATES TABLES
-- -- Table structure for table `careers` -- CREATE TABLE IF NOT EXISTS `careers` ( `career_id` int(11) NOT NULL auto_increment, `career_name` varchar(75) NOT NULL, `career_desc` text NOT NULL, `degree_needed` enum('Yes','No') NOT NULL, `useful_info` text, `useful_links` text, PRIMARY KEY (`career_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=34 ; -- -------------------------------------------------------- -- -- Table structure for table `course` -- CREATE TABLE IF NOT EXISTS `course` ( `course_id` int(11) NOT NULL auto_increment, `course_type` varchar(75) NOT NULL, `course_names` text NOT NULL, `extra_needed` enum('Yes','No') default NULL, `course_link` varchar(150) NOT NULL, `grades_grade_id` int(11) NOT NULL, PRIMARY KEY (`course_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=87 ; -- -------------------------------------------------------- -- -- Table structure for table `grades` -- CREATE TABLE IF NOT EXISTS `grades` ( `grade_id` int(11) NOT NULL auto_increment, `grade_desc` text NOT NULL, `careers_career_id` int(11) NOT NULL, PRIMARY KEY (`grade_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=87 ; -- --------------------------------------------------------
An overview of my theory behind tables is that each class is associated with a career, and one career may have many grades, of which one course is associated with only one course, but the user may need to take an additional course if the one they choose is not sufficiently accredited .
So my question is how to choose course details for higher level courses if the user selects a low level course,
for example, the user wants to be an electrician, and they have 2 class D at school, which means that they can only do a level 2 course, which means that they must take a higher level course to complete the course. I need to show that other courses are based on the fact that they chose an electrician and a level 2 course, it is worth noting that courses that require additional work have an extra_needed field that is marked as yes.
I can’t live or work on how to get the data I need, I tried the following:
SELECT * FROM `course` , `grades` , `careers` WHERE `course`.`extra_needed` IS NULL AND `grades`.`grade_id` = `careers`.`career_id` AND `careers`.`career_id` =6
however, this returns 59 rows of data, where it should return 2 rows of data, and the other in the data rows that the user could select if they had selected other choices.