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

Join problem in SQL statement

Status
Not open for further replies.

dom24

Programmer
Aug 5, 2004
218
GB
Can anyone help me with this statement:

SELECT Staff.StaffNo, Validation.Completed, LName, FName, Staff.ManagerNo, CourseName,
CourseDate, ManagerEvaluation.CourseKey as CourseKey2, ManagerEvaluation.ManagerNo as ManagerNo2,
ManagerEvaluation.StaffNo as StaffNo2, ManagerEvaluation.Completed as Completed2
FROM Validation
INNER JOIN Staff on Validation.StaffNo = Staff.StaffNo INNER JOIN Course on Validation.CourseKey = Course.CourseKey
INNER JOIN ManagerEvaluation on Validation.StaffNo = ManagerEvaluation.StaffNo
where Staff.ManagerNo = '10514T' and ManagerEvaluation.Completed IS NOT NULL

I want to pull back all the records from MangerEvaluation where ManagerEvaluation.Completed IS NOT NULL.

This seems to be pulling back both the NULLS and NOT NULLS.

Thanks.
 
Try this:
where Staff.ManagerNo = '10514T' and (ManagerEvaluation.Completed IS NOT NULL OR ManagerEvaluation.Completed <> "")

-L
 
instead of this
Code:
and ManagerEvaluation.Completed IS NOT NULL

try this
Code:
and isnull(ManagerEvaluation.Completed,'X')<> 'X'
 
No doesn't like it. Error message is:

Cannot use empty object or column names. Use a single space if necessary.

I think i've got something wrong with the joins actually cos it's pulling back the data even without the WHERE clause. It's pulling all data from the Validation table AND the ManagerEvaluation table.
 
If you just want to get records from the ManagerEvaluation table then use a RIGHT JOIN instead of INNER JOIN.

-L
 
hneal 98 - won't work cos it's a date field.
Lothario - use a right join where? On all the joins?
 
On just the last one..something like this:

RIGHT JOIN ManagerEvaluation on Validation.StaffNo = ManagerEvaluation.StaffNo

-L
 
May be its better that you provide some data and the kind of result you are looking for.

that way someone here can suggest you in the right way.

-L
 
then change it to
Code:
and isnull(ManagerEvaluation.Completed,'12/31/2078')<> '12/31/2078'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top