Greetings, I have 3 tables in my SQL database as follows
Table Users2
UserID,
EID,
Name,
Email,
Department,
Enabled
Table Sites
SiteID,
SiteCode,
SiteName
Table UserSites2
UsersSitesID,
UserID,
SiteID
What I need to do is, given EID and SiteID, get a full row from the Users2 table AND the SiteID, SiteCode and SiteName from the Sites table WHEN the userID of the retrieved record has an entry in the UserSites2 Table. Here is a sampling of data..
Users2
1, 12345, Me, [email protected], Support, True
2, 12346, you, [email protected], Service, True
Sites
1, 123, Regional HQ
2, 234, National HQ
UserSites2
1, 1, 1
2, 1, 2
3, 2, 2
So given EID 12345 and Site ID 2 I should get the result
1, 12345, Me, [email protected], Support, True, 2, 234, National HQ
and for EID 12346 and SiteID 1 i should get nothing
i know how to join Users2 and Sites to get the full row I want but I don't understand how to make it depend on wether there is an entry in the lookup table for it.