Here is my database layout:
Institution:
...inst_id
...inst_name
IsUser:
...user_id
...login
...Institution_ inst_id
Membership:
...IsUser_user_ id
...Role_role_id
Role:
...role_id
...Institution_ inst_id
...role_name
The Database is the back end for an application. When a user is created they are NOT assigned a role. But this can be done later. I need to return all users and associated information from the other tables. I can do this for all users in a role using the membership table, the problem is the users that are not assigned a role are not in the membership table and I have nothing to join on. any ideas? here is my working SQL that returns users in a role:
("SELECT i.user_id, i.login, r.role_name, r.role_id, t.inst_name, t.inst_id from IsUser i, Role r, Membership m, Institution t where i.user_id = m.IsUser_user_i d and r.role_id = m.Role_role_id ORDER BY t.inst_name, r.role_name")
I have a feeling I may have to Use two different SQL statements, but I would like to do the job in one.
Also IsUser.Institut ion_inst_id --> Role.Institutio n_inst_id --> Institution.ins t_id
Thanks for the help.
Institution:
...inst_id
...inst_name
IsUser:
...user_id
...login
...Institution_ inst_id
Membership:
...IsUser_user_ id
...Role_role_id
Role:
...role_id
...Institution_ inst_id
...role_name
The Database is the back end for an application. When a user is created they are NOT assigned a role. But this can be done later. I need to return all users and associated information from the other tables. I can do this for all users in a role using the membership table, the problem is the users that are not assigned a role are not in the membership table and I have nothing to join on. any ideas? here is my working SQL that returns users in a role:
("SELECT i.user_id, i.login, r.role_name, r.role_id, t.inst_name, t.inst_id from IsUser i, Role r, Membership m, Institution t where i.user_id = m.IsUser_user_i d and r.role_id = m.Role_role_id ORDER BY t.inst_name, r.role_name")
I have a feeling I may have to Use two different SQL statements, but I would like to do the job in one.
Also IsUser.Institut ion_inst_id --> Role.Institutio n_inst_id --> Institution.ins t_id
Thanks for the help.
Comment