Consultor Eletrônico



Kbase P52392: Last condition of SQL-92 WHERE clause has no effect on the r
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   1/20/2004
Status: Unverified

FACT(s) (Environment):

HP-UX 11.0

FACT(s) (Environment):

Progress 9.1D

SYMPTOM(s):

Last condition of SQL-92 WHERE is not limiting records returned as expected.

Executing a Query similar to the following:

SELECT
Name
FROM
pub.customer
WHERE
Name > ' ' AND
Country = 'USA' OR
Balance > 100000 AND
CreditLimit > -1;

The Query returns the same result set whether the condition CreditLimit > -1 is there or not.

CAUSE:

There are no records satisfying the condition:

(Balance > 100000

Hence there would be no records satisfying the condition:

(Balance > 100000 AND CreditLimit > -1;)

Therefore the result set will be the one returned by the left side of the OR operator, namely the condition:

(Name > ' ' AND Country = 'USA')

FIX:

The Query is returning the correct result set. To get a different the result, change the Query logic. Use parenthesis to combine conditions as desired.