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

Not all records show with Left Join

Status
Not open for further replies.

hceonetman

Technical User
Mar 16, 2001
92
US
I have a query created by the query builder in Access 2000. SEI is a table containing all employees. SAI contains absence info, including sick and vacation, etc. The query prompts for payid. I enter a valid id (the record definitely exists in SEI). The only records for the employee in SEI are for 'Vacation', which is excluded by the SQL statement. My understanding of 'Left Join' is that all records from SEI should show, even if there is no match in SAI. When I run it I get a nothing in the result.

Following is the statement created by the SQL builder:

SELECT [SEI].PayID, [SEI].SubDeptName, [SEI].LName,[SEI].FName, [SEI].Name, [SAI].ReasonID, [SAI].ReasonCat, [SAI].ReasonType, [SAI].ReasonDetails, [SAI].AbsenceDate,
FROM [SEI] LEFT JOIN [SAI] ON [SEI].PayID = [SAI].PayID
WHERE ((([SEI].PayID)=[Enter PayID]) AND (([SAI].ReasonCat)<>&quot;Vacation&quot; ;

Is it something in Access, or just my understanding of the join properties?

Thanks in advance,
HCEONETMAN
 
Try this:

Code:
SELECT [SEI].PayID, [SEI].SubDeptName, [SEI].LName,[SEI].FName, [SEI].Name, [SAI].ReasonID, [SAI].ReasonCat, [SAI].ReasonType, [SAI].ReasonDetails, [SAI].AbsenceDate 
FROM [SEI] LEFT JOIN [SAI] ON [SEI].PayID = [SAI].PayID
WHERE ([SAI].ReasonCat<>&quot;Vacation&quot; OR [SAI].ReasonCat Is Null);
[pc2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top