Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Correlated Query help
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00494635
Message ID:
00494640
Vues:
21
>>Hi All,
>>This works in SQL Server, however VFP cannot handle the complexity. :( I'm not sure how to rewrite it.
>>SELECT S.Clm_Id, S.Svc_Dt ;
>>	FROM Mc_MdSvc S, Mc_MdClm C ;
>>	WHERE C.Adjt_Stat = "Z" ;
>>	AND C.Clm_Id = S.Clm_Id ;
>>	AND NOT EXISTS (SELECT * FROM Mc_PlnHs P ;
>>				WHERE P.Mem_Num = C.Mem_Num ;
>>				AND P.Active_Ind = .T. ;
>>				AND P.Pln_Id = C.Pln_Id ;
>>				AND P.Ins_Id_Num = C.Ins_Id_Num ;
>>				AND P.Eff_From <= S.Svc_Dt ;
>>				AND P.Eff_Thru >= S.Svc_Dt)
>>
>>What it chokes on is the last 2 lines of the subquery. It only can handle equality. Any Ideas?
>
>I don't think your subquery knows anything about your "S" alias since it's in the main query.

Hi Fred,
This is a correlated subquery. The value from the main query will be substituted in the inner query for each of the rows in the main query. It's a way to get a loop in SQL!

However, the error I get is that VFP only allows equality in correlated subqueries. The error is as follows:
SQL: Error correlating fields (Error 1801)
An outer reference can be used only in syntax similar to the following:

X = Y

Syntax such as X = Y + 1 or X = 5 will produce this error.
Bill Armbrecht
VFP MCP
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform