I've been asked to add some more information to a web page.
The original select statement works fine, my problem is in the change that I have to make.
Basically I think that I need to do a select based on the results of the first select.
Here's the statement.
I've separated the selects to make it easier to see where I'm at.
I need to take the LearningPlanID from the main select and use it for my where clause in the sub select.
Is this possible or do I need to separate it into a second select statement? My preference is not to do this because having to iterate through the results of the first select to get the values for the second would really slow down the generating of the html page.
"Every day is like a precious gift, you have to make it count" James Birrell 1993-2001
The original select statement works fine, my problem is in the change that I have to make.
Basically I think that I need to do a select based on the results of the first select.
Here's the statement.
Code:
SELECT employer.name, employer.address1, employer.address2, employer.city, employer.postalcode, employercontact.ContactID, employercontact.FirstName, employercontact.LastName, employerContact.phoneNumber , employercontact.Extension, employerContact.emailAddress, employerContact.Comments, employerContact.faxNumber, employer.schoolID, schools.name AS schoolname, LearningPlan.LearningPlanID AS myLearningPlan ,
(select Schools.Name FROM (((schools INNER JOIN teachers on schools.id=teachers.schoolID) INNER JOIN students ON students.teacherID = Teachers.teacherID) INNER JOIN LearningPlan ON learningplan.studentID=students.studentID) WHERE
LearningPlan.LearningPlanID = myLearningPlan )
as myLearningPlanSchool
FROM (((Employer LEFT JOIN Employercontact on Employer.EmployerID = EmployerContact.EmployerID) LEFT JOIN schools on Employer.SchoolID = Schools.ID) LEFT JOIN LearningPlan on LearningPlan.contactID = EmployerContact.contactID)
WHERE employer.employerid = 9738
ORDER BY employercontact.ContactID ASC
I've separated the selects to make it easier to see where I'm at.
I need to take the LearningPlanID from the main select and use it for my where clause in the sub select.
Is this possible or do I need to separate it into a second select statement? My preference is not to do this because having to iterate through the results of the first select to get the values for the second would really slow down the generating of the html page.
"Every day is like a precious gift, you have to make it count" James Birrell 1993-2001