Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is this possible in one or two SQL Select?
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01236995
Message ID:
01237006
Vues:
15
>It can be done with SQL Select if you build query dynamicly based on MY_TBL2
>
>CLEAR
>CREATE CURSOR my_tbl1 (my_value i)
>INSERT INTO my_tbl1 VALUES(1)
>INSERT INTO my_tbl1 VALUES(2)
>INSERT INTO my_tbl1 VALUES(2)
>INSERT INTO my_tbl1 VALUES(1)
>INSERT INTO my_tbl1 VALUES(3)
>CREATE CURSOR my_tbl2 (my_value i, my_caption C(20))
>INSERT INTO my_tbl2 VALUES(1, "Caption 1")
>INSERT INTO my_tbl2 VALUES(2, "Caption 2")
>INSERT INTO my_tbl2 VALUES(3, "Caption 3")
>
>lcColStr = ""
>SELECT my_tbl2
>SCAN
>	lcColAlias = CHRTRAN(ALLTRIM(my_caption), SPACE(1), "_")
>	lcColExpr  = [IIF(t1.my_value = ] + TRANSFORM(my_value) + [,.T., .F.)]
>	lcColStr = lcColStr + [, ] + lcColExpr + [ AS ] + lcColAlias
>ENDSCAN
>
>TEXT TO lcSql TEXTMERGE NOSHOW PRETEXT 15
>	SELECT t1.my_value <<lcColStr>>
>		FROM my_tbl1 t1 JOIN my_tbl2 t2 ON t1.my_value = t2.my_value
>ENDTEXT
>
>&lcSql
>
Sergey,

Thank you very much!
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform