rider_student rider_major 1. Write a SQL statement which joins the rider_student
ID: 3846132 • Letter: R
Question
rider_student
rider_major
1. Write a SQL statement which joins the rider_student table with the rider_major table and lists the rider student name and the name of the major (major_name) and the description of the major for which they are currently assigned. (You may use the SQL 'join' subclause, or simply express the join as part of the 'where' clause by indicating that you only want records where the primary key of the child table, rider_major, equals the corresponding foreign key of the joined table, rider_student.)
2. Write a SQL statement which joins the rider_student table with the rider_major table and lists the rider student name and the name of the major (major_name) and the description of the major for which they are currently assigned. The SQL statement should only select records for students who are majoring in Accounting.
3. Write a SQL statement which joins the rider_student table with the rider_major table and lists the rider student name and the name of the major (major_name) and the description of the major for which they are currently assigned. The SQL statement should only select records for majors for graduates (graduate_only = 'TRUE').
Column Data Type Description student_id integer the primary key first_name varchar(25) student first name last_name varchar(25) student lats name major_id integer the ID of the student's major; a foreign key for the major_id in the rider_major tableExplanation / Answer
1) SELECT first_name,last_name,major_name,major_description
FROM rider_student,rider_major
WHERE rider_sudent.major_id=rider_major.major_id;
2)SELECT first_name,last_name,major_name,major_description
FROM rider_student,rider_major
WHERE rider_student.major_id=rider_major.major_id AND major_name='Accounting';
3)SELECT first_name,last_name,major_name,major_description
FROM rider_student,rider_major
WHERE rider_student.major_id=rider_major.major_id AND graduate_only='True';
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.