Table 1 : dbt_m_user (user_id, user_name, email_id, . . . . . )
Table 2 : dbt_m_user_profile (user_id, profile_id, . . . . .)
I have e-mail id of an user who has particular profile (role). Now I need names of users who are having same access profile.
I could get the results from below, but it looks very raw and doesn't seem to be elegant one, considering that there are only 2 tables.
select user_name from dbt_m_user where user_id in (
select user_id from dbt_m_user_profile where profile_id in (
select profile_id from dbt_m_user_profile where user_id in (
select user_id from dbt_m_user where Email_Id = 'snehal.masne@db.com' )))
Can this be improvised by using special clauses/joins ?