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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:38:42+00:00 2026-06-18T11:38:42+00:00

Suppose I have two different ID’s assigned for same record. For example RecordID |

  • 0

Suppose I have two different ID’s assigned for same record. For example

RecordID | ID1 | ID2
--------------------
1        | X   | A
2        | X   | B
3        | Y   | C
4        | Y   | C
5        | Y   | D
6        | Z   | E
7        | Z   | E

Now, I want to get the records where ID1 is assigned to the same value where as ID2 is assigned to a different value.

For example, I want to get:

1, X, A
2, X, B

Here ID1 assigned it X where as ID2 assigned it A and B, two different values.

Is it possible to write a query in SQL or SQL server that will return such records?

  • 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-18T11:38:43+00:00Added an answer on June 18, 2026 at 11:38 am

    You need to use a subquery where, for each row, you poke through the table and see if any other rows match a certain criteria related to it.

    pseudo sql:

    select 
          t1.id, 
          t1.variable, 
          t1.value 
       from 
          table t1 
       where 
          exists ( select 1 
                      from t2 
                      where t2.id != t1.id 
                        and t2.variable == t1.variable 
                        and t2.value != t1.value)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have two distinct databases with identical schemas but different data. I want
Suppose I have two boolean variables, and I want to do completely different things
Suppose I have two h:inputText components. I want to bind both of the text
Suppose I have two different arrays. Emails = ["email@email.com", "email1@email.com", "email2@email.com"] Names = ["Name
Suppose I have two or more different server applications developed in Clojure using ZeroMQ
I have two variables from two different SQL queries that I want to put
Suppose we have two installed APKs with the same service and same action per
Say I have two different cpp files. Both declare classes with the same name,
Suppose I just created a package example and have two classes inside it, Main
Suppose I have two different structures, Struct1 and Struct2. They both have different elements

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.