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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:36:30+00:00 2026-06-11T17:36:30+00:00

I want to compare two tables that has the same columns but different number

  • 0

I want to compare two tables that has the same columns but different number of rows. How do I find which rows are unique to each table? I found some join tutorials but it needs primary key to join two tables, my sample tables have no relation to each other.

Sample table:

TableA
Id | Name
1 | Person1
2 | Person2
3 | Person3
4 | Person4

TableB
Id | Name
1 | Person1
2 | Person2
4 | Person4

Sample result:
Id | Name
3 | Person3

Optional result:
Id | Name | Table
3 | Person3 | TableA
  • 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-11T17:36:31+00:00Added an answer on June 11, 2026 at 5:36 pm

    This query selects rows from TableA that are not present in TableB plus the rows from TableB not present in TableA, using a UNION statement.

    SELECT Id, Name, 'TableA' FROM TableA
    WHERE (Id, Name) NOT IN
    (SELECT Id, Name FROM TableB)
    UNION
    SELECT Id, Name, 'TableB' FROM TableB
    WHERE (Id, Name) NOT IN
    (SELECT Id, Name FROM TableA)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to compare two tables to find rows in each table that
I would like to compare two columns in the same table. I want to
I want to create a merge that will compare two tables and insert not
I have two rows from a table that has many columns. How do I
I want to compare two CSV files to see if they are different. I
I have a search form field that I want to compare with multiple columns
I have a table called Task which has, among others, two columns: Date_due: a
I have two tables, both have the same columns. We will call them tilistings
I have two hash tables. I want to compare values of both the hash
I have two SQL tables with data that I would like to compare. 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.