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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:35:20+00:00 2026-06-10T19:35:20+00:00

I have a table in my Oracle DB with data stored such as ROLE_ID

  • 0

I have a table in my Oracle DB with data stored such as

ROLE_ID | USER_ID
------------------
 14     | USER A
 15     | USER A
 11     | USER B
 13     | USER A
 15     | USER B
 12     | USER C
 15     | USER C

I want to get all the USER_IDs which have ROLE_ID of both 13 and 15. Based on the example above, I should only get back USER_A.

If I write the query below

select * from table where ROLE_ID in (13,15); then I get other users as well.

How can I modify the query so that I only get back USER A

  • 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-10T19:35:21+00:00Added an answer on June 10, 2026 at 7:35 pm

    You’re looking for having…

    select user_id
      from my_table
     where role_id in (13,15)
     group by user_id.
    having count(distinct role_id) = 2
    

    You ensure, by using the distinct, that if there is say two USER A’s that you still get one where it has both role_ids

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

Sidebar

Related Questions

I have to get data from Oracle Table in which I have one datefield
In Oracle I've created a data type: TABLE of VARCHAR2(200) I want to have
I'm trying to call an Oracle Stored Procedure which returns XMLType data, but all
We have data stored in oracle 10g db which contains french character set. The
I have a table part with a few demo data as below in Oracle
In Oracle, I have a table with a column of data type NUMBER. I
I have a table in Oracle where one of the column contains UserIds which
I have a table in Oracle 11.2 database. I want the database to run
I have a oracle table A which contains a column A.a which used to
we have a table in an Oracle Database which contains a column with the

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.