In: Computer Science
COURSE : IT Enterprise systems
Consider the Relations below
STUDENT
Student# |
Std-Name |
Address |
1 |
Smith |
Jeddah |
2 |
Bob |
Buraidah |
3 |
Alice |
Dammam |
COURSE
Student# |
Course Code |
Course-Name |
1 |
IT241 |
Operating System |
2 |
IT210 |
Computer Network |
2 |
IT445 |
Decision Support System |
Write a query using the Right Outer Join to retrieve the record from the two relations. Also, construct the table displaying the output of your query.
note: NEED A UNIQUE ANSWER AND NO HANDWRITING PLEASE..
THANK YOU
Query: SELECT T1.Student,T1.StdName,T1.Address,T2.CourseCode,T2.CourseName FROM STUDENT AS T1 RIGHT OUTER JOIN COURSE AS T2 ON T1.Student=t2.Student
SQL Program:
BEGIN TRANSACTION;
/* Create a table called NAMES */
CREATE TABLE STUDENT(Student integer PRIMARY KEY, StdName text,
Address text);
/* Create few records in this table */
INSERT INTO STUDENT VALUES(1,'Smith','Jeddah');
INSERT INTO STUDENT VALUES(2,'Bob','Buraidah');
INSERT INTO STUDENT VALUES(3,'Alice','Damman');
CREATE TABLE COURSE(Student integer PRIMARY KEY, CourseCode text, CourseName text);
/* Create few records in this table */
INSERT INTO COURSE VALUES(1,'IT241','Operating System');
INSERT INTO COURSE VALUES(2,'IT210','Computer Network');
INSERT INTO COURSE VALUES(3,'IT445','Decision Support System');
COMMIT;
/* Display all the records from the table */
SELECT * FROM STUDENT;
SELECT * FROM COURSE;
/* Query for Right Outer Join */
SELECT T1.Student,T1.StdName,T1.Address,T2.CourseCode,T2.CourseName
FROM STUDENT AS T1 RIGHT OUTER JOIN COURSE AS T2 ON
T1.Student=t2.Student
1 Smith Jeddah
IT241 Operating System
2 Bob Buraidah
IT210 Computer Network
3 Alice Damman
IT445 Decision Support System
OUTPUT: