Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6807545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:50:43+00:00 2026-05-26T19:50:43+00:00

I have first table like this: ID Email 100 a@a.com 200 b@b.com I have

  • 0

I have first table like this:

ID    Email   

100  a@a.com  
200  b@b.com

I have second table like this(permissions shared):

   ID   Assigned ID  Role
   100    200        Normal user
   100    100        Super user
   200    200        Normal user 

ie. 100 is a super user and can access the sharing features of ID 200.

select t1.ID,t1.email,t2.role from table t1, table t2 where t1.ID=t2.ID;

When I combine both the top 2 tables, i get like this

ID     Email      Role

100    a@a.com    Super  user 
100    a@a.com    Normal user
200    b@b.com    Normal user

I want to get output like this:

ID     Email      Role    
100    a@a.com    Super  user 
200    b@b.com    Normal user

ie. If any user has a type of super user rights, just take that entry and don’t need the type for normal user.

If the email is already present as super user and further the same email is assigned to someone, then the query should return only for super user.

I even tried using group by and union all:

  select t1.ID,t1.email,t2.role from table t1, table t2 
  where t1.ID=t2.ID group by t1.email having t2.role='Super user'
  and not exists (  select t1.ID,t1.email,t2.role from table t1, table t2 
  where t1.ID=t2.ID group by t1.email having t2.role='Super user')
  UNION ALL
  select t1.ID,t1.email,t2.role from table t1, table t2 
  where t1.ID=t2.ID group by t1.email having t2.role<>'Super user';

but seemed to give incorrect answer. Any thoughts?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:50:44+00:00Added an answer on May 26, 2026 at 7:50 pm

    “If any user has a type of super user rights, just take that entry and don’t need the type for normal user”:

    
    select t1.ID,t1.email,t2.role 
    from   table t1, table t2
    where  t1.ID=t2.ID 
      and  t2.ID = t2.Assigned_ID
    

    since you don’t need results where users are acting with another role.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have user table having fields gender and first name like this.. The value
I have a table like this: |sub_account|name|email| |-----------|----|-----| // same account and same name:
i have a table (tbl_world) which look like this id | first_name | last_name
I have a table like so <table> <tr id=trRow1 runat=server style=display: none> <td>First Name:</td>
I have two tables kinda like this: // Person.Details Table: PersonID int [PK] |
I have a user table 'users' that has fields like: id first_name last_name ...
I have first names stored in one table and last names stored in another.
I have database with many tables. In the first table, I have a field
I have a performance problem on a query. First table is a Customer table
I have a database framework where I have two tables. The first table has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.