I have two tables which are linked by a joint table:
Staff (one) <-- (many) StaffRights
StaffRights (many) --> (One) Rights
Table1 --> Staff
StaffID: PK
Name
Table2 --> StaffRights
SRID: PK
StaffID:FK
RightID:FK
CreatedTS
Table3 -->Rights
RightID: PK
RightName
And I want to select columns from all the tables doing something like this:
Select s.Name, s.StaffID, sr.RightID, r.RightSelectName
From Staff s
INNER JOIN StaffRights sr ON s.StaffID = sr.StaffID
INNER JOIN Rights r ON sr.RightID = r.RightID
Where sr.DeletedTS IS NULL AND s.DeletedTS IS NULL AND s.IsSelfservice = 0 s.Name =
'myquery1' AND s.Pwd = 'myquery2'