Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Cross Reference
Message
 
 
À
12/03/2003 18:42:35
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
00765193
Message ID:
00765203
Vues:
16
>Hi All,
>
>If I have the following table 'Customers'
>Id Ref First Last
>-- --- ----- ----
>10 10  John  Unknown
>25 10  Jane  Doe
>
>I am having problem combine the two records together using the select statement. If I select Id = 25 and also want to retrieve all the info where Ref=10. The result should like >> 25 10 Jane Doe John Unknown
>
>Is this possible with one select statement. TIA

You can do this with SQL Select and UDF() combination.
SELECT Id, ref,  combfl(Id, ref) AS flist;
 FROM mytable ;
 GROUP BY 1,2

...
FUNCTION combfl
LPARAMETERS lcId, lcref
LOCAL laList[1], lcStr, i
SELECT First, Last FROM mytable  ;
	WHERE if = lcId, Ref = lcref ;
	INTO ARRAY laList
	
lcStr = ""	
FOR i=1 TO _TALLY
	lcStr = lcStr + " " + Trim(laList[i,1]) + " " + Trim(laList[i,2])
ENDFOR
RETURN PADR(lcStr, 254)
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform