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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:33:53+00:00 2026-05-30T15:33:53+00:00

I am using java/oracle. i have below issue. SELECT DISTINCT id_one, status FROM sometable

  • 0

I am using java/oracle. i have below issue.

SELECT
         DISTINCT id_one,
         status 
     FROM
         sometable 
     WHERE
         id_two IN (
             SELECT
                 DISTINCT id_two  
             FROM
                 othertable
         ) 
         AND id_one IN (1946,1948,1949)  

i have above query to fetch data from one table. inner query’s data from other table.
now i need add one where condition to inner query.
othertable has one more field called name.

these are the ids that i mentioned: 1946,1948,1949. here each id will have names as below: name1, name2, name3
name1, name2, name3 are passed from java application.

finally the query that i need as follows.

SELECT
         DISTINCT id_one,
         status 
     FROM
         sometable 
     WHERE
         id_two IN (
             SELECT
                 DISTINCT id_two  
             FROM
                 othertable other where other.name in('name1','name2','name3')
         ) 
         AND id_one IN (1946,1948,1949)  

my questions is: for 1946 id name1 should be considered and for 1948 id name2 should be considered
*and for 1949 id name3 should be considered as criteria.* i mean query should not consider all 3 names for every id.

how can i achieve it?

  • 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-30T15:33:54+00:00Added an answer on May 30, 2026 at 3:33 pm

    This can also be done like in the following way:

    select distinct s.id_one, s.status
      from sometable s join othertable o on (s.id_two = o.id_two)
     where (s.id_one = 1946 and o.name = 'name1')
        OR (s.id_one = 1948 and o.name = 'name2')
        OR (s.id_one = 1949 and o.name = 'name3');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im using Oracle, BlazeDS, Java & Flex. I have an ArrayCollection containing data from
I have some Java code that connects to an Oracle database using DriverManager.getConnection(). It
Below is my Oracle Procedure. When i call this procedure using java, it throws
I'm currently wrestling with an Oracle SQL DATE conversion problem using iBATIS from Java.
We are using Java and Oracle for development. I have table in a oracle
I have a problem with my WebLogic Oracle server, now I'm using Java EE
I am developing an application using oracle 11g, Java(struts2) and Hibernate. I have table
I am using Java + iBatis and have a need to call an Oracle
I have downloaded Java API documentation from http://www.oracle.com/technetwork/java/javase/downloads/index.html#docs and have supposedly attached it to
I have a problem during an insert in Oracle using Java and JDBC. 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.