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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:33:09+00:00 2026-05-29T09:33:09+00:00

I have two tables looking like this: A B id_attr value id id_attr value

  • 0

I have two tables looking like this:

       A                        B
id_attr  value         id   id_attr  value
--------------         -------------------
  1        a            1       2       b
  2        b            1       3       c        
  3        c            2       2       b
  4       NULL          2       4       d
                        2       5       e
                        3       1       aaa
                        3       3       c

Table A is my reference table and I have multiple entries in table B. (every group of entries with the same id cosists of pairs of (id_attr,value) similiar to structure of table A). Goal is to check if entry in table A matches any of the entries in table B (one or more). One entry matches another when every attribute existing in table B under one id matches similiar attributes in table A. Also, in table A values could be NULL, but in table B not.

In example above my query should return “1”, becouse only entries with id 1 fully match similiar entries in table A. Id 2 doesn’t match, becouse in table A value of attribute 4 is NULL and it has an attribute which doesn`t exist in table A. Id 3 doesn’t match either even if attribute 3 is similiar, but attribute 1 doesn’t match.

As you can see to achieve a match not every one of the entries existing in table A should be matching, but if an attribute exists in table B then it value has to match similiar value in table A.

What is the most efficient way to achieve this result in an Oracle query?

Every help would be greatly appreciated. I can provide answers to further questions if I didn’t express myself clear enough.

  • 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-29T09:33:10+00:00Added an answer on May 29, 2026 at 9:33 am

    You can try the following:

    SELECT ID, MIN(IS_OK) FROM
    (
      SELECT B.ID ID, 
             DECODE(B.VALUE, A.VALUE, 'Y', 'N') IS_OK
      FROM A INNER JOIN B 
      ON B.ID_ATTR = A.ID_ATTR
    )
    GROUP BY ID;
    

    Which will return you B’s ID and a flag that indicates whether this ID is OK or not.

    (Note that Decode will properly take care of the null values comparison without having to test for null values)

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

Sidebar

Related Questions

I have two tables: CREATE TABLE items ( root_id integer NOT NULL, id serial
I have a query which searches two separate fields in the same table... looking
I have two tables: Table 1: ID, PersonCode, Name, Table 2: ID, Table1ID, Location,
Imagine I have two tables in a DB like so: products: product_id name ----------------
I have two tables that I designed this way with a possible reshuffling of
I am looking for some help with a MYSQL query. I have two tables,
I have two tables detail and head. The detail table will be written first.
I am a bit stumped on this. Basically I have two tables: Page: id
I have a Database with the following two tables, USERS, POSTS I am looking
I have two tables, one an import table, the other a FK constraint on

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.