Using Left Join on 3 Tables

Results 1 to 2 of 2

Thread: Using Left Join on 3 Tables

  1. #1
    Join Date
    Dec 1969

    Default Using Left Join on 3 Tables

    Hi, I have two tables that I need to pull information from. Unfortunetly, they are joined by the data of a third table. Example: Teams.Name, Teams.Team_ID -&#062; Members.Team_ID, Members.Emp_ID (for Role_ID 1 only) -&#062; Emp.Emp_ID, Emp.Name.<BR><BR>What I need is the Teams.Name and the Emp.Name. Also, I need all of the Teams.Name even if they don&#039t show up in the other tables. I have made the following query, but it only gives me teams that have employee names tied to them. Please take a look at it and see if you can help. Thanks in advance.<BR><BR>SELECT per_Teams.Team_Name,<BR> per_Teams.Team_ID, <BR> per_Personnel.Emp_Full_Name <BR>FROM per_Teams <BR>LEFT JOIN per_Team_Membership <BR> ON per_Teams.Team_ID=per_Team_Membership.Team_ID <BR>LEFT JOIN per_Personnel <BR> ON per_Personnel.Emp_ID = per_Team_Membership.Emp_ID <BR>WHERE per_Team_Membership.Role_ID=1"<BR><BR><BR>Brandon.

  2. #2
    John Weeflaar Guest

    Default RE: Using Left Join on 3 Tables

    After the last line:<BR>WHERE per_Team_Membership.Role_ID=1<BR>you can try to add this:<BR>OR per_Team_Membership.Role_ID Is Null<BR><BR>Hope it helps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts