Information générale
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Curious query behavior
I have 2 SQL queries on local tables. They essentially do the same thing, one for active customers, one for inactive. Both get their results from 2 preliminary queries and 2 local tables. They both have the following in the where clause (include customers in the county list or in the zip code table):
(AT(ALLTRIM(co_county) + ",",cCountyList)>0 OR ;
SUBSTR(in_zip,1,5) IN ;
(SELECT Zip FROM hcfa_zip))
My question is this: This works fine in the first query (active). It does not work in the second. If I take the condition on either side of the OR by itself, it works fine in both queries. The county list and zip tables are the same for each. The active query includes an additional condition after this that the inactive does not. Is there anything in the query itself or the preliminary queries (order, etc.) that could affect this? I have matched everything I can in the 2 queries, and have tried different things with the preliminary queries, but to no avail. I can modify the code to get the right result. I’m just curious why it works on one and not the other (what affects the results).
TIA
John
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement