Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sql select to get one record with data from n records
Message
De
08/07/2009 07:46:18
Salminen Jukka
Js Software Systems
Vaasa, Finlande
 
 
À
06/07/2009 09:04:09
Albert Beermann
Piepenbrock Service Gmbh & Cokg
Osnabrück, Allemagne
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Database:
MySQL
Divers
Thread ID:
01410248
Message ID:
01410843
Vues:
27
>Hello Everybody
>
>I have a table/cursor "standardinfos" with default infos.(customer = 9911)
>I have another table/cursor "customerinfos" with variable special infos.
>The second table has columns fieldname,fieldvalue, linkkey
>When doing a left join from standardinfos to customer infos i get a result with 1 to n rows (4 rows in the following example)
>
>Now i need the records from table/cursor customerinfos in one record
>
>Fieldname Fieldvalue Linkkey
>F1 xyz 9911
>F2 123 9911
>F3 Blah 9911
>F4 4711 9911
>
>The wanted result should should look like:
>F1 F2 F3 F4 linkkey
>xyz 123 Blah 4711 9911
>
>Until now i select the customer standardinfo record into cursor a.
>Then i select the customerinfos into cursor b.
>Then i scan through cursor b and build an dynamic "create cursor" command.
>Create cursor c (linkkey,f1,f2,f3,f4)
>Than i do a second scan with append blank in c and replace c.linkkey with 9911,c.f1 with xyz,c.f2 with 123 ...
>At last i select the data from a and c to get a one record result cursor
>Looks stupid but works.
>
>Is there an SQL command to get the wanted result ???
>(Now i have the same data/table construction on a MySQL Webserver.)
>
>Any help welcomed

If you are interested of more general solutions this article might help:
http://databases.aspfaq.com/general/how-do-i-concatenate-strings-from-a-column-into-a-single-row.html
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform