Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Inner Join Challenge
Greg Rosoff 
     
7 months ago
Good afternoon!  I'm trying to build a tool for Access Control and have the following query:

SELECT
    U.UserID,
    U.UserName,
    BF1.BusinessFunctionName AS BusinessFunction1,
    BF2.BusinessFunctionName AS BusinessFunction2,
    BF3.BusinessFunctionName AS BusinessFunction3,
    SRL.SOD_Risk_ID,
    SR.SOD_Risk_Description
FROM
    (Users AS U
INNER JOIN
    UserSystemRoles AS USR_Temp ON U.UserID = USR_Temp.UserID)
INNER JOIN
    (SystemRoles AS SRol_Temp ON USR_Temp.SystemRoleID = SRol_Temp.SystemRoleID)
INNER JOIN
    (SystemRoleBusinessFunctions AS SRBF ON SRol_Temp.SystemRoleID = SRBF.SystemRoleID)
INNER JOIN
    (BusinessFunctions AS BF ON SRBF.BusinessFunctionID = BF.BusinessFunctionID)
INNER JOIN
    (SOD_Risk_Lookup AS SRL ON BF.BusinessFunctionID = SRL.BusinessFunctionID1)
LEFT JOIN SOD_Risks AS SR ON SRL.SOD_Risk_ID = SR.SOD_Risk_ID
LEFT JOIN BusinessFunctions AS BF1 ON SRL.BusinessFunctionID1 = BF1.BusinessFunctionID
LEFT JOIN BusinessFunctions AS BF2 ON SRL.BusinessFunctionID2 = BF2.BusinessFunctionID
LEFT JOIN BusinessFunctions AS BF3 ON SRL.BusinessFunctionID3 = BF3.BusinessFunctionID
WHERE EXISTS (
    SELECT 1
    FROM SystemRoleBusinessFunctions AS SRBF2
    INNER JOIN SystemRoles AS SRol2 ON SRBF2.SystemRoleID = SRol2.SystemRoleID
    INNER JOIN UserSystemRoles AS USR2 ON SRol2.SystemRoleID = USR2.SystemRoleID
    INNER JOIN BusinessFunctions AS BF_Matching ON SRBF2.BusinessFunctionID = BF_Matching.BusinessFunctionID
    WHERE USR2.UserID = U.UserID
    AND (BF_Matching.BusinessFunctionID = SRL.BusinessFunctionID2
    OR BF_Matching.BusinessFunctionID = SRL.BusinessFunctionID3)
)
;

I keep getting a syntax error on the second Inner Join "ON"--UserSystemRoles AS USR_Temp ON U.UserID = USR_Temp.UserID) I have double checked the relationships, the accuracy of the fields' names and table name.  I'm going crazy on this!
Adam Schwanz  @Reply  
           
7 months ago
Dumb it down to the bare minimum and slowly built it back again one join at a time. To help find the problem.

More than likely you have null or some data somewhere that it doesn't like.
Lars Schindler  @Reply  
     
7 months ago
I would guess that the brackets are not placed correctly.
INNER JOIN
    (SystemRoles AS SRol_Temp ON USR_Temp.SystemRoleID = SRol_Temp.SystemRoleID)
At least to me, this does not look correct, because brackets are not usually opened after ‘INNER JOIN’, are they?
John Davy  @Reply  
         
7 months ago
Follow Adam's advice- it is good advice.  John
Richard Rost  @Reply  
           
7 months ago
My brain hurts looking at that lol. Yeah, like they said, simplify it, start from scratch, and just put it together one piece at a time, testing each step of the way to make sure it works.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 4/30/2026 3:28:45 PM. PLT: 1s