Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Full Outer Join with 3 tables in MySQL

Author  Topic 

EonsNearby
Starting Member

1 Post

Posted - 2011-10-12 : 13:57:58
Okay, I have to perform a full outer join on three different tables:

student (with attributes ID, name, dept_name, tot_cred) and the following data:
'00128', 'Zhang', 'Comp. Sci.', '102'
'12345', 'Shankar', 'Comp. Sci.', '32'
'19991', 'Brandt', 'History', '80'
'23121', 'Chavez', 'Finance', '110'
'44553', 'Peltier', 'Physics', '56'
'45678', 'Levy', 'Physics', '46'
'54321', 'Williams', 'Comp. Sci.', '54'
'55739', 'Sanchez', 'Music', '38'
'70557', 'Snow', 'Physics', '0'
'76543', 'Brown', 'Comp. Sci.', '58'
'76653', 'Aoi', 'Elec. Eng.', '60'
'98765', 'Bourikas', 'Elec. Eng.', '98'
'98988', 'Tanaka', 'Biology', '120'

instructor (with attributes ID, name, dept_name, salary) and the following data:
'10101', 'Srinivasan', 'Comp. Sci.', '65000.00'
'12121', 'Wu', 'Finance', '90000.00'
'15151', 'Mozart', 'Music', '40000.00'
'22222', 'Einstein', 'Physics', '95000.00'
'32343', 'El Said', 'History', '60000.00'
'33456', 'Gold', 'Physics', '87000.00'
'45565', 'Katz', 'Comp. Sci.', '75000.00'
'58583', 'Califieri', 'History', '62000.00'
'76543', 'Singh', 'Finance', '80000.00'
'76766', 'Crick', 'Biology', '72000.00'
'83821', 'Brandt', 'Comp. Sci.', '92000.00'
'98345', 'Kim', 'Elec. Eng.', '80000.00'

advisor (with attributes s_ID and i_ID) and the data:
'00128', '45565'
'12345', '10101'
'23121', '76543'
'44553', '22222'
'45678', '22222'
'76543', '45565'
'76653', '98345'
'98765', '98345'
'98988', '76766'

Basically the resulting relation should have the name of the student and then the name of his advisor, and obviously since there are more instructors than students, some instructors will have null values for their respective students. Any help will be appreciated.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-12 : 14:02:49
If you're using MySQL please post it in some MySQL forums like www.dbforums.com
This is MS SQL Server forum and solutions given here are specific to SQL Server and might not work on MySQL

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -