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 9014175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:26:49+00:00 2026-06-16T03:26:49+00:00

I have a table with application name and permissions given to the application. i

  • 0

I have a table with application name and permissions given to the application. i need to find what are the applications that require both these

name   permissions
app1    perm1
app1    perm5
app1    perm6
app2    perm1
app2    perm8
app3    perm1
app3    perm6
app3    perm2
app3    perm4

How do i find the application names which has “perm1 and perm6” both….?

  • 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-06-16T03:26:50+00:00Added an answer on June 16, 2026 at 3:26 am

    Here’s one way to do it.

    SELECT t.name
      FROM mytable t
     GROUP BY t.name
    HAVING MAX(IFNULL(t.permissions,'')='perm1')
         + MAX(IFNULL(t.permissions,'')='perm6') = 2
     ORDER BY t.name
    

    We’re using a GROUP BY and aggregate functions, if we find a row for that has ‘perm1′, then t.permissons=’perm1’ returns a 1, otherwise it returns a 0. (We handle the case of a NULL by wrapping t.permissions in an IFNULL function.)

    If we find both a ‘perm1’ and a ‘perm6’, then the HAVING predicate will evalulate to TRUE, and the row will be returned.


    Another way to do it, using an EXISTS predicate to run a correlated subquery:

    SELECT t.name
      FROM mytable t
     WHERE t.permissions = 'perm1'
       AND EXISTS 
           ( SELECT 1 
               FROM mytable s
              WHERE s.name = t.name
                AND s.permissions = 'perm6'
           )
     GROUP BY t.name
     ORDER BY t.name
    

    or an equivalent, using an IN predicate:

     SELECT t.name
       FROM mytable t
      WHERE t.permissions = 'perm1'
        AND t.name IN 
            ( SELECT s.name
                FROM mytable s
               WHERE s.permissions = 'perm6'
                 AND s.name IS NOT NULL
               GROUP BY s.name
            )
      GROUP BY t.name
      ORDER BY t.name
    

    A fourth way to get it would be:

     SELECT t.name
       FROM mytable t
       JOIN mytable s
         ON t.name = s.name
        AND t.permissions = 'perm1'
        AND s.permissions = 'perm6'
      GROUP BY t.name
      ORDER BY t.name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table from a vendor application that stores some xml data into
I currently have a Web Application which is using it's own Permissions table which
I have this table rss_user. You see account name, application name and application type.
I have the following scenario: Database A.table A.name Database A.table A.Application Database B.table B.name
I have a table like this: Application,Program,UsedObject It can have data like this: A,P1,ZZ
I have problem with my application. I have table report, there are 2 column
I have a table created in sql. but in my application I am using
I'm working on rails application with postgres db.I have a table called merchant_review_votes where
I have two tables, a user table and a application table: User id username
My application is in ASP.net MVC3. I have a table of elements. An element

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.