Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

outer join question

Status
Not open for further replies.

myatia

Programmer
Nov 21, 2002
232
0
0
Hi,

I have three tables, Instructor, InstructorZipCode, and InstructorClassification, that I want to join together. All instructors have a zip code, but some don't have a classification. I want to get all the instructors within n miles of a zip code, regardless of whether they have a classification. I have the math worked out to do that, I just need help on the join. I've tried the following

Code:
SELECT *

FROM (SELECT * FROM Instructor, InstructorZipCode WHERE (math crap) AS InstructorTable) 
LEFT OUTER JOIN Classification

WHERE InstructorTable.ClassificationID = Classification.ClassificationID

but that doesn't work (I get an error in the from clause). I think I have the right idea; I'm just not sure about the syntax (then again, maybe not ;). If anyone could offer me some pointers, I'd really appreciate it. Thanks,

Misty

 
I think you forgot the ON statement

SELECT *
FROM (SELECT * FROM Instructor, InstructorZipCode WHERE (math crap)) AS InstructorTable
LEFT OUTER JOIN Classification
ON InstructorTable.ClassificationID = Classification.ClassificationID

Perhaps this will help

karel.denaeghel@barco.com
 
Thanks! That change, along with moving the "AS InstructorTable" outside of the parantheses, as shown below, made it work. I appreciate your help.

misty

Code:
SELECT *
		
FROM	

(
   SELECT  *
   FROM    Instructor, InstructorZipCode
   WHERE  (math stuff)
) AS InstructorTable
		
LEFT OUTER JOIN Classification
		
ON Classification.ClassificationID = InstructorTable.ClassificationID
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top