简体   繁体   中英

Trouble with Joins (SQL on Oracle)

I have a few tables:

See them here

I need to get some data from them both. I must list all Computer Science Alumni from 2014 (from AlumnusDeg table), and include their name email and home phone number (from Alumnus table).

The following code returns the Computer Science Alumni from 2014:

SELECT * FROM AlumnusDeg 
WHERE DegreeName LIKE '%Computer Science%' 
AND YearGraduated = '2014';

However every other attempt at also getting the remaining FirstName, LastName, Email and HomeNo just aren't working.

Finally, I must create this as a view.

You need simple join, as I understand

SELECT * 
FROM AlumnusDeg ad JOIN Alumnus a on ad.alumniid=a.alumniid
WHERE DegreeName LIKE '%Computer Science%' 
AND YearGraduated = '2014';
SELECT ad.*, FirstName, LastName, Email, HomeNo
FROM alumnus a
INNER JOIN alumnusdeg ad ON a.AlumniID = ad.AlumniID
WHERE DegreeName LIKE '%Computer Science%' 
AND YearGraduated = '2014';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM