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

The Archive Base Latest Questions

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

Hello I’ve been working on this all morning. I thought it was a simple

  • 0

Hello I’ve been working on this all morning. I thought it was a simple self join but the self join actually returns too many rows.

Essentially I’m trying to find rows in a table where certain column values match row to row.

So if row one and three have the same column values in three specific columns then those two rows are returned.

So far I’ve tried a self-join, and a semi-join in a couple of different ways.

SELECT * 
FROM ATable a, ATable b
Where  a.colValue = b.colValue
and    a.colValue2 = b.colValue2

This returns too many rows.
Is this query even a join? Am I on the wrong track here?
What am I missing about self joins that it returns more rows than the table itself?

ATable contains 20 rows but above query returns 36.

As Always thanks very much for any answers or hints. I learn alot just by formulating the question.

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

    The query at the moment will return every row, because all rows are equal to themselves.
    You need to restrict it so that they must be different rows.

    I’m assuming you have some sort of Primary Key ID column.

    SELECT * 
    FROM ATable a, ATable b
    Where  a.colValue = b.colValue
    and    a.colValue2 = b.colValue2
    and    a.Id!= b.Id
    

    Another thing you have to consider is that if you had the rows:

    ID      ColValue     ColValue2   ColValue3
    1           A            B            C
    2           A            B            D
    

    You’d see:

    a.id a.ColValue a.ColValue2 a.ColValue3 b.id b.ColValue b.ColValue2 b.ColValue3
    1    A          B           C           2    A          B           D
    2    A          B           D           1    A          B           C
    

    Because Row 1 is the same as Row 2. But also Row 2 is the same as Row 1.

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

Sidebar

Related Questions

Hello! I've been programming for a long time but just started developing for android,
Hello all I am working on javascript jquery and svg.I want to ask a
Hello all I am working on html and javascript.And I am going to ask
hello all i am working on a project in which i have a webpage
Hello all and thanks for your time reading this. I need to verify certificates
hello all i am new to iphone development i am working on a application
Hello all I'm working on a little project where I'm adding controls to a
Let's say I'm outputting a post title and in our database, it's Hello Y’all
Hello I have like this 2 tables class User public int UserId{get;set;} { ....
Hello I've got this query to get users by email, which is an unique

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.