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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:30:44+00:00 2026-06-15T08:30:44+00:00

I am trying to compare two addresses from the same ID to see whether

  • 0

I am trying to compare two addresses from the same ID to see whether they match. For example:

Id  Adress Code     Address
1   1               123 Main
1   2               123 Main
2   1               456 Wall
2   2               456 Wall
3   1               789 Right
3   2               100 Left

I’m just trying to figure out whether the address for each ID matches. So in this case I want to return just ID 3 as having a different address for Address Code 1 and 2.

  • 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-15T08:30:45+00:00Added an answer on June 15, 2026 at 8:30 am

    Join the table with itself and give it two different aliases (A and B in the following example). This allows to compare different rows of the same table.

    SELECT DISTINCT A.Id
    FROM
        Address A
        INNER JOIN Address B
            ON A.Id = B.Id AND A.[Adress Code] < B.[Adress Code]
    WHERE
        A.Address <> B.Address
    

    The “less than” comparison < ensures that you get 2 different addresses and you don’t get the same 2 address codes twice. Using “not equal” <> instead, would yield the codes as (1, 2) and (2, 1); each one of them for the A alias and the B alias in turn.

    The join clause is responsible for the pairing of the rows where as the where-clause tests additional conditions.


    The query above works with any address codes. If you want to compare addresses with specific address codes, you can change the query to

    SELECT A.Id
    FROM
        Address A
        INNER JOIN Address B
            ON A.Id = B.Id
    WHERE                     
        A.[Adress Code] = 1 AND
        B.[Adress Code] = 2 AND
        A.Address <> B.Address
    

    I imagine that this might be useful to find customers having a billing address (Adress Code = 1 as an example) differing from the delivery address (Adress Code = 2) .

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

Sidebar

Related Questions

I'm trying to compare two UIImages from the file system to see if they
I'm trying to compare two arrays to see if they match- My test cases
simply trying to compare two user defined vectors to see if they are equal,
I am trying to compare two dates. I have this code which I thought
I am trying to compare two dates but I can t see how it
I have following code I am trying to compare two get in order to
I am trying to compare the addresses of two variables in memory: chunk_t *old_chunk,
I'm trying to compare two Xml files using C# code. I want to ignore
I'm trying to compare two arrays both 2d, I need it only match when
I am trying to compare two Ruby Hashes using the following code: #!/usr/bin/env ruby

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.