ATOUTFOX
COMMUNAUTÉ FRANCOPHONE DES PROFESSIONNELS FOXPRO
Visual FoxPro : le développement durable

Forum AtoutFox : Re: Comment eviter les doublons dans une requête ?   

Sujet

rss Flux RSS des derniers messages

Vous devez vous identifier pour pouvoir poser une question ou répondre.

mar. 30 août 2016, 16h18
Gregory Adam
Belgique Belgique

atoutfox.public.association

Re: Comment eviter les doublons dans une requête ?

Bernard,

De rien.

Parfois les JOIN ne donnent pas de resultats voulus quand il a plusieurs lignes


Une solution est celle que j'ai donnee

Une autre est d'employer
select ...... from PremiereTable ;
     where exists ( select 1 from AutreTable where AutreTable .Clef = PremiereTable.Clef)



Quant a la ' sous-requête à cet endroit' c'est nouveau dans vfp9
Voir l'aide : What's New in Visual FoxPro / SQL Language Improvements

Sub-SELECT in the FROM Clause
A sub-SELECT is often referred to as a derived table. Derived tables are SELECT statements in the FROM clause referred to by an alias or a user-specified name. The result set of the SELECT in the FROM clause creates a table used by the outer SELECT statement. Visual FoxPro 9.0 permits the use of a subquery in the FROM clause.

A sub-SELECT should be enclosed in parentheses and an alias is required. Correlation is not supported. A sub-SELECT has the same syntax limitations as the SELECT command, but not the subquery syntax limitations. All sub-SELECTs are executed before the top most SELECT is evaluated.

The following is the general syntax for a subquery in the FROM clause.

SELECT … FROM (SELECT …) [AS] Alias…

Example
The following example demonstrates the use of a subquery in the FROM clause.

SELECT * FROM (SELECT * FROM MyCursor T1;
   WHERE field1 = (SELECT T2.field2 FROM MyCursor1 T2;
   WHERE T2.field1=T1.field2);
   UNION SELECT * FROM MyCursor2;
   ORDER BY 2 desc) AS subquery

*** Note that the following code will generate an error ***
SELECT * FROM (SELECT TOP 5 field1 FROM MyCursor) ORDER BY field1


Permalink : http://www.atoutfox.org/nntp.asp?ID=0000017828
20 286 messages dans le forum • Liste complète des messages

www.atoutfox.org - Site de la Communauté Francophone des Professionnels FoxPro - v3.4.0 - © 2004-2026.
Cette page est générée par un composant COM+ développé en Visual FoxPro 9.0-SP2-HF3