rider_student rider_major 1. Write a SQL statement which joins the rider_student
ID: 3846133 • 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 major_name,last_name,first_name from rider_major,rider_student where rider_major.major_id=rider_student.student_id;
2)
select major_name,last_name,first_name from rider_major,rider_student where rider_major.major_id=rider_student.student_id and major_name='Accounting';
3)
select major_name,last_name,first_name,major_description from rider_major,rider_student where rider_major.major_id=rider_student.student_id and major_description='true';
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.