dbTalk Databases Forums  

What am I missing here?

comp.database.oracle.misc comp.database.oracle.misc


Discuss What am I missing here? in the comp.database.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
sheldonlg
 
Posts: n/a

Default What am I missing here? - 05-29-2008 , 02:50 PM






I am probably missing something very obvious, but after looking and
looking I just don't see it.

I have the following query:

SELECT DISTINCT A.AMT, A.CONTRACT
FROM ATABLE A, BTABLE B, CTABLE C
WHERE
( (B.X = '011170' AND B.Y = A.W)
OR
(C.M = A.Z AND C.N = A.T)
)
AND A.FYEAR = '2008'
AND A.FPRNO='3'

This yields an empty set.
However, if I remove the OR part and just have:

SELECT DISTINCT A.AMT, A.CONTRACT
FROM ATABLE A, BTABLE B
WHERE
( (B.X = '011170' AND B.Y = A.W)
)
AND A.FYEAR = '2008'
AND A.FPRNO='3'

Then it returns data.

Since (B.X = '011170' AND B.Y = A.W) is true and
(C.M = A.Z AND C.N = A.T) is false, shouldn't the compound statement in
the parenthesis in the first one, separated by an OR, yields true, and
so should yield data? It is acting as if (true or false) ===> false
rather than true.

Reply With Quote
  #2  
Old   
Gordon Burditt
 
Posts: n/a

Default Re: What am I missing here? - 05-29-2008 , 04:07 PM






Quote:
I am probably missing something very obvious, but after looking and
looking I just don't see it.
You not only removed the OR, you also removed the join to table C.
A join with an empty table C won't return any data regardless of
the WHERE clause.

I have to wonder if you really mean 'OR' (as distinguished from
'AND'). Assuming there is one rows from the join of A and B that
satisfies:

B.X = '011170' and B.Y = A.W and A.FYEAR = '2008' and A.FPRNO='3'

and there are one million rows in table C, regardless of contents,
you're going to get one million rows returned.

Quote:
I have the following query:

SELECT DISTINCT A.AMT, A.CONTRACT
FROM ATABLE A, BTABLE B, CTABLE C
WHERE
( (B.X = '011170' AND B.Y = A.W)
OR
(C.M = A.Z AND C.N = A.T)
)
AND A.FYEAR = '2008'
AND A.FPRNO='3'

This yields an empty set.
However, if I remove the OR part and just have:

SELECT DISTINCT A.AMT, A.CONTRACT
FROM ATABLE A, BTABLE B
WHERE
( (B.X = '011170' AND B.Y = A.W)
)
AND A.FYEAR = '2008'
AND A.FPRNO='3'

Then it returns data.

Since (B.X = '011170' AND B.Y = A.W) is true and
(C.M = A.Z AND C.N = A.T) is false, shouldn't the compound statement in
the parenthesis in the first one, separated by an OR, yields true, and
so should yield data? It is acting as if (true or false) ===> false
rather than true.
If table C is empty, there are no records in the join, so the WHERE
clause is never evaluated.



Reply With Quote
  #3  
Old   
Gordon Burditt
 
Posts: n/a

Default Re: What am I missing here? - 05-29-2008 , 04:07 PM



Quote:
I am probably missing something very obvious, but after looking and
looking I just don't see it.
You not only removed the OR, you also removed the join to table C.
A join with an empty table C won't return any data regardless of
the WHERE clause.

I have to wonder if you really mean 'OR' (as distinguished from
'AND'). Assuming there is one rows from the join of A and B that
satisfies:

B.X = '011170' and B.Y = A.W and A.FYEAR = '2008' and A.FPRNO='3'

and there are one million rows in table C, regardless of contents,
you're going to get one million rows returned.

Quote:
I have the following query:

SELECT DISTINCT A.AMT, A.CONTRACT
FROM ATABLE A, BTABLE B, CTABLE C
WHERE
( (B.X = '011170' AND B.Y = A.W)
OR
(C.M = A.Z AND C.N = A.T)
)
AND A.FYEAR = '2008'
AND A.FPRNO='3'

This yields an empty set.
However, if I remove the OR part and just have:

SELECT DISTINCT A.AMT, A.CONTRACT
FROM ATABLE A, BTABLE B
WHERE
( (B.X = '011170' AND B.Y = A.W)
)
AND A.FYEAR = '2008'
AND A.FPRNO='3'

Then it returns data.

Since (B.X = '011170' AND B.Y = A.W) is true and
(C.M = A.Z AND C.N = A.T) is false, shouldn't the compound statement in
the parenthesis in the first one, separated by an OR, yields true, and
so should yield data? It is acting as if (true or false) ===> false
rather than true.
If table C is empty, there are no records in the join, so the WHERE
clause is never evaluated.



Reply With Quote
  #4  
Old   
Gordon Burditt
 
Posts: n/a

Default Re: What am I missing here? - 05-29-2008 , 04:07 PM



Quote:
I am probably missing something very obvious, but after looking and
looking I just don't see it.
You not only removed the OR, you also removed the join to table C.
A join with an empty table C won't return any data regardless of
the WHERE clause.

I have to wonder if you really mean 'OR' (as distinguished from
'AND'). Assuming there is one rows from the join of A and B that
satisfies:

B.X = '011170' and B.Y = A.W and A.FYEAR = '2008' and A.FPRNO='3'

and there are one million rows in table C, regardless of contents,
you're going to get one million rows returned.

Quote:
I have the following query:

SELECT DISTINCT A.AMT, A.CONTRACT
FROM ATABLE A, BTABLE B, CTABLE C
WHERE
( (B.X = '011170' AND B.Y = A.W)
OR
(C.M = A.Z AND C.N = A.T)
)
AND A.FYEAR = '2008'
AND A.FPRNO='3'

This yields an empty set.
However, if I remove the OR part and just have:

SELECT DISTINCT A.AMT, A.CONTRACT
FROM ATABLE A, BTABLE B
WHERE
( (B.X = '011170' AND B.Y = A.W)
)
AND A.FYEAR = '2008'
AND A.FPRNO='3'

Then it returns data.

Since (B.X = '011170' AND B.Y = A.W) is true and
(C.M = A.Z AND C.N = A.T) is false, shouldn't the compound statement in
the parenthesis in the first one, separated by an OR, yields true, and
so should yield data? It is acting as if (true or false) ===> false
rather than true.
If table C is empty, there are no records in the join, so the WHERE
clause is never evaluated.



Reply With Quote
  #5  
Old   
Gordon Burditt
 
Posts: n/a

Default Re: What am I missing here? - 05-29-2008 , 04:07 PM



Quote:
I am probably missing something very obvious, but after looking and
looking I just don't see it.
You not only removed the OR, you also removed the join to table C.
A join with an empty table C won't return any data regardless of
the WHERE clause.

I have to wonder if you really mean 'OR' (as distinguished from
'AND'). Assuming there is one rows from the join of A and B that
satisfies:

B.X = '011170' and B.Y = A.W and A.FYEAR = '2008' and A.FPRNO='3'

and there are one million rows in table C, regardless of contents,
you're going to get one million rows returned.

Quote:
I have the following query:

SELECT DISTINCT A.AMT, A.CONTRACT
FROM ATABLE A, BTABLE B, CTABLE C
WHERE
( (B.X = '011170' AND B.Y = A.W)
OR
(C.M = A.Z AND C.N = A.T)
)
AND A.FYEAR = '2008'
AND A.FPRNO='3'

This yields an empty set.
However, if I remove the OR part and just have:

SELECT DISTINCT A.AMT, A.CONTRACT
FROM ATABLE A, BTABLE B
WHERE
( (B.X = '011170' AND B.Y = A.W)
)
AND A.FYEAR = '2008'
AND A.FPRNO='3'

Then it returns data.

Since (B.X = '011170' AND B.Y = A.W) is true and
(C.M = A.Z AND C.N = A.T) is false, shouldn't the compound statement in
the parenthesis in the first one, separated by an OR, yields true, and
so should yield data? It is acting as if (true or false) ===> false
rather than true.
If table C is empty, there are no records in the join, so the WHERE
clause is never evaluated.



Reply With Quote
  #6  
Old   
sheldonlg
 
Posts: n/a

Default Re: What am I missing here? - 05-29-2008 , 08:27 PM



Gordon Burditt wrote:

Quote:
If table C is empty, there are no records in the join, so the WHERE
clause is never evaluated.

That is the answer.




Reply With Quote
  #7  
Old   
sheldonlg
 
Posts: n/a

Default Re: What am I missing here? - 05-29-2008 , 08:27 PM



Gordon Burditt wrote:

Quote:
If table C is empty, there are no records in the join, so the WHERE
clause is never evaluated.

That is the answer.




Reply With Quote
  #8  
Old   
sheldonlg
 
Posts: n/a

Default Re: What am I missing here? - 05-29-2008 , 08:27 PM



Gordon Burditt wrote:

Quote:
If table C is empty, there are no records in the join, so the WHERE
clause is never evaluated.

That is the answer.




Reply With Quote
  #9  
Old   
sheldonlg
 
Posts: n/a

Default Re: What am I missing here? - 05-29-2008 , 08:27 PM



Gordon Burditt wrote:

Quote:
If table C is empty, there are no records in the join, so the WHERE
clause is never evaluated.

That is the answer.




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.