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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:43:54+00:00 2026-06-16T01:43:54+00:00

I have two tables with exactly the same columns Table A id FLAG 1

  • 0

I have two tables with exactly the same columns

Table A

id   FLAG
1    Y
2    Y
3    N
4    N

Table B

id   FLAG
1    Y
2
3    N
4

I would like to write a select query in Oracle that will display all rows in Table A where the FLAG column is not the same as Table B but having matching ID’s columns

The result should be as follows.

id   FLAG
2    Y
4    N
  • 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-16T01:43:56+00:00Added an answer on June 16, 2026 at 1:43 am

    “all rows in Table A … as Table B having matching ID’s columns”:

    FROM a JOIN b USING (id)
    

    “where the FLAG column is not the same”:

    WHERE a.flag != b.flag 
       OR (a.flag IS NULL AND b.flag IS NOT NULL)
       OR (b.flag IS NULL AND a.flag IS NOT NULL)
    

    So, the query would be

    SELECT id, a.flag
      FROM a JOIN b USING (id)
    WHERE a.flag != b.flag 
       OR (a.flag IS NULL AND b.flag IS NOT NULL)
       OR (b.flag IS NULL AND a.flag IS NOT NULL)
    

    The WHERE-condition is ugly but necessary to catch the cases where table b has a NULL-value, but a not, or the other way round…

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

Sidebar

Related Questions

I have two tables with exactly the same schema. I would like to have
I have two tables with exactly the same fields. Table A contains 7160 records
I have two tables which I would like to place side-by-side exactly as they
I have two different views to the same database table and I would like
Scenario I have an TWO datbase tables of exactly the SAME STRUCTURE. The difference
I have two tables like so: create table doi ( id number primary key
I have two tables defined for actual and expected with exactly the same schema.
I have two tables: account_company and document_invoice. Table account_company has 2 columns: company_id and
I have two data tables and would like to join the two tables to
I have two tables, lets say table1 and table2 with common columns, id and

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.