Question : SQL Query - 2 Tables

Hi

I have two tables. Table A has team members in it. Each row in the table has the member id and the team id. Tables B is the users table. In table B there are multiple fields that can have a Team ID in it, 6 fields to be exact. This is all in an MS Access Table. I want to have a query that will product a list of users that are assigned to the teams and a member is in. For example;

Team Member 'JMUR' is in the following teams; T001,T002,T003,T004,T008,T009. I want to list all the users in table that have any of the teams in 1 of the 6 fields that can hold Team ID's. My attempt is as follows:

Table A = c_team_members, Table B = c_users

    sql_str = "SELECT c_users.account_name," & _
                    " c_users.public_id, " & _
                    " c_team_members.public_id " & _
                    " FROM c_users " & _
                    " WHERE c_team_members.public_id = '" & lwProfile.public_id & "' " & _
                        "INNER JOIN c_users ON c_users.lw_pre_record_alert_amber = c_team_members.team_pid OR " & _
                        "c_users ON c_users.lw_post_record_alert_amber = c_team_members.team_pid OR " & _
                        "c_users ON c_users.lw_pre_record_alert_red = c_team_members.team_pid OR " & _
                        "c_users ON c_users.lw_post_record_alert_red = c_team_members.team_pid OR " & _
                        "c_users ON c_users.lw_tpa_override_RA_team = c_team_members.team_pid OR " & _
                        "c_users ON c_users.map_response_team = c_team_members.team_pid "

Many Thanks

Answer : SQL Query - 2 Tables

Hi Thanks for all your efforts, I have solved my problem; here it is -

sql_str = "SELECT c_teams_members.public_id, c_users.account_name, c_users.public_id " & _
              "FROM c_teams_members INNER JOIN c_users ON " & _
              "(c_teams_members.team_pid = c_users.lw_tpa_override_RA_team) AND " & _
              "(c_teams_members.team_pid = c_users.map_response_team) AND " & _
              "(c_teams_members.team_pid = c_users.lw_post_record_alert_amber) AND " & _
              "(c_teams_members.team_pid = c_users.lw_pre_record_alert_amber) AND " & _
              "(c_teams_members.team_pid = c_users.lw_post_record_alert_red) AND " & _
              "(c_teams_members.team_pid = c_users.lw_pre_record_alert_red) " & _
              "WHERE (((c_teams_members.public_id)='" & lwProfile.public_id & "'))"

wProfile.public_id in this case would be 'JMUR'

I don't know what to with a question that I solved, you can have the points if you like, but I cannot accept your solution. Is this fair or maybe you can advice me on the most appropriate action....
Random Solutions  
 
programming4us programming4us