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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting for table display 1

Status
Not open for further replies.

mjstone323

Technical User
Jan 11, 2002
57
US
I apologize if this has been answered elsewhere - I'm having trouble formulating my question, and thus it's difficult to know what to search for!

I have a query such that the result is displayed in two related select boxes:

SELECT School.SchoolID, School.SchoolName, School.SchoolOpen, Employee.EmployeeID, Employee.SchoolID, Employee.CertificationTracking, Employee.FirstName, Employee.LastName, (Employee.FirstName + ' ' + Employee.LastName) as TeacherName
FROM School, Employee
WHERE SchoolOpen <> 0 AND Employee.SchoolID = School.SchoolID AND Employee.CertificationTracking <> 0
ORDER BY School.SchoolName, LastName, FirstName


These are employees who are being tracked for certification. Not all the employees are being tracked, so I created a boolean column (CertificationTracking). The above query works great.

It turns out that other employees would like to attend the workshops, who aren't being tracked for certification, so I created another boolean column (AttendsWorkshops) and tried to list them along with the other, tracked employees thusly:

...
WHERE SchoolOpen <> 0 AND Employee.SchoolID = School.SchoolID AND Employee.CertificationTracking <> 0 OR Employee.AttendsWorkshops <> 0
...

But this resulted in all schools, whether or not they're open, and all teachers, whether or not they're being tracked, to be listed.

My brain is frozen. What am I doing wrong?
 
Add the parens as below

WHERE SchoolOpen <> 0 AND Employee.SchoolID = School.SchoolID AND ( Employee.CertificationTracking <> 0 OR Employee.AttendsWorkshops <> 0 )
 
Thank you!!! I thought perhaps it needed some parentheses... wasn't sure where to put them :O
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top