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

  • Home
  • SEARCH
  • 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 6737077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:12:21+00:00 2026-05-26T11:12:21+00:00

Hi Need help to resolve some complicated query. I’ll send the input username (say

  • 0

Hi Need help to resolve some complicated query. I’ll send the input username (say test ) to the query. I have to list the other users with the same role of the username test and also those usernames should be match with all the groupid of the username test. If the other user has more groups than username test is not an issue, but should match all the groupdid exists in the username test. I tried the following query. It wil return no rows if all the groupids matches. But, I need the username those who have match with all the group id instead of returning no rows for the exact match.

select 
  group_id 
from 
  user_info us ,group_privilege_details gp 
where 
  login_name='test' 
  and us.user_id = gp.user_id 
EXCEPT
select 
  group_id 
from 
  user_info u ,group_privilege_details g 
where login_name !='test' 
and role_id in (select role_id 
                from user_info 
                where login_name ='test')
and group_id in (select group_id 
                 from user_info us ,group_privilege_details gp 
                 where login_name='test' 
                 and us.user_id = gp.user_id ) 
and g.user_id = u.user_id

Thanks in advance. And sorry for long explanation

  • 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-26T11:12:22+00:00Added an answer on May 26, 2026 at 11:12 am

    If I understand correctly you want:

    select all users,
            not being user test,
            with same role as user test,
            where not exists a group where user test is a member of
                and the other user is not a member of
    

    In SQL that is something like the following. I used the following abbreviations: OU other user, TU test user, TUG test user’s groups, OUG other user’s groups.

    select OU.login_name, OU.user_id
        from user_info OU, user_info TU
        where OU.user_id <> TU.user_id 
            and OU.role_id = TU.role_id 
            and TU.login_name = 'test'
            and not exists (
                select * from group_privilege_details TUG
                    where TUG.user_id = TU.user_id
                        and TUG.group_id not in (
                            select group_id 
                                from group_privilege_details OUG 
                                where OUG.user_id = OU.id
                        )
            )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, I am stumped on this one and need some quick help. I have
I need help understanding some C++ operator overload statements. The class is declared like
i need help with disk_total_space function.. i have this on my code <?php $sql=select
I need some help with my program. I get this error when I run
I'm having a hard time wrapping my head around this and need some help
Please help me to resolve the following problem: First of all, I have one
I have struts2 web application. Right now I need embed with help of iframe
I need some clarifications for ASP.NET Membership; please help me with it. I am
I have a need to run some automation tasks in a web browser control
I have some code in a javascript file that needs to send queries back

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.