We help IT Professionals succeed at work.
Get Started

Help with Oracle query - to find a set of rows that don't meet specific conditions across tables

mgferg
mgferg asked
on
701 Views
Last Modified: 2012-08-21
Hi all,


I have two tables, say tableA and tableB (tableB is via a dblink on a different server).

first we want to restrict our query to those rows on tableA that have condition='a'

then from this list, find the rows that DO NOT meet the following:
tableA,colx=tableB,colx
tableA,coly=tableB,coly
tableA,colz=tableB,colz

eg.

tableA
condition  colx coly colz
a                1      2      3
a                4      5      6
b                7      8      9
c               10   11     12
a               13   14     15

tableB
colx coly colz
1      2      3
4      5      X
7      X      9
X     11    12
13    X      15


so the rows we want are the ones on tableA has 4 5 6 and 13 14 15  because colz on tableA does not match colz on tableB

We don't care about the mismatches  7 X 9 and X 11 12 because tableA does not have an 'a' in the condition column.

Any help would be much appreciated (and I can elaborate on this if required - I've tried to keep it simple to demonstrate the principle of what I'm trying to do)

DB is Oracle10G and I'm using sql developer to run any queries.

Thanks,

Mark
Comment
Watch Question
Senior Oracle DBA
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE