How to join two tables with relationship (1 Viewer)

isladogs

MVP / VIP
Local time
Today, 21:53
Joined
Jan 14, 2017
Messages
18,212
Yes, I did.
Your attachment is beyond my knowledge in MS Access.
I will try to add some fields in the table tblFacilityRegister, and I will let you know how it helps.

Thanks a lot for your kind efforts.

All you need to do is copy & paste the query SQL into your database!

Code:
SELECT tblFacilityRegister.ID, tblFacilityRegister.SenderID, tblFacilityRegister.ReceiverID, tblFacilityRegister.ScannedBy, [tblSenders].[FirstName] & ' ' & [tblSenders.LastName] AS SenderName, [tblReceivers].[FirstName] & ' ' & [tblReceivers].[LastName] AS ReceiverName, [tblScanners].[FirstName] & ' ' & [tblScanners].[LastName] AS ScannedByName
FROM ((tblUsers AS tblSenders INNER JOIN tblFacilityRegister ON tblSenders.UserID = tblFacilityRegister.SenderID) INNER JOIN tblUsers AS tblReceivers ON tblFacilityRegister.ReceiverID = tblReceivers.UserID) INNER JOIN tblUsers AS tblScanners ON tblFacilityRegister.ScannedBy = tblScanners.UserID;

What's difficult about that?
Here's the same query in design view



The 3 tables tblSenders, tblReceivers, tblScanners are 3 copies of tblUsers where I've used an alias to distinguish them
 

Attachments

  • QueryDesign.PNG
    QueryDesign.PNG
    36 KB · Views: 192
Last edited:

Pat Hartman

Super Moderator
Staff member
Local time
Today, 16:53
Joined
Feb 19, 2002
Messages
43,257
If all three FK fields are defined as required, this query will be fine but if they are not defined as required, then the joins need to be left joins.
 

isladogs

MVP / VIP
Local time
Today, 21:53
Joined
Jan 14, 2017
Messages
18,212
If all three FK fields are defined as required, this query will be fine but if they are not defined as required, then the joins need to be left joins.

I'd already stated about using outer vs inner joins back in posts 2 & 5.
However, as the OP has decided its all too difficult, it makes no difference anyway!
 
Last edited:

Alhakeem1977

Registered User.
Local time
Today, 23:53
Joined
Jun 24, 2017
Messages
308
Thank you all for your responses, I got it solved by added Users to the Relationships window three times as " The_Doc_Man " recommended, then I did the same in the query too but I changed the Join Properties option 3.

Thanks again to all for interactions, specifically " ridders " I tried the code you provided I got some issues I do not know from where actually but I if I built my database perfectly it will work for sure.

Best Regards,
Alhakeem1977
 

isladogs

MVP / VIP
Local time
Today, 21:53
Joined
Jan 14, 2017
Messages
18,212
Glad you got it solved .... but what you did sounds exactly like the solution I provided earlier - see post 21
 

Alhakeem1977

Registered User.
Local time
Today, 23:53
Joined
Jun 24, 2017
Messages
308
Glad you got it solved .... but what you did sounds exactly like the solution I provided earlier - see post 21
Thanks, I see I'm new in MS Access that's why I can't understand many concepts, you are so advanced.

Thank you very much.
 

Users who are viewing this thread

Top Bottom