Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Get column from derived table
Message
 
 
À
11/06/2014 13:24:49
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01601694
Message ID:
01601699
Vues:
26
>>I know that this topic was discussed before (I probably ask myself this question before) but I forgot how to do it.
>>
>>I have a parent and child tables. I need to show all records in the parent table and one column from child table. So that the resulting query has only one record per parent table. When I do LEFT JOIN the resulting query has as many records as there are records in the child table. I know (I think) it has to be done with derived column but I forgot how. Here is an example:
>>
>>
>>select table1.fld1, table1.fld2, table2.fld1 (... this is where I think the field table2.fld1 has to be created ) from table1
>>
>>
>>TIA
>
>If you want only one record, you need to specify how you get the child data. You can get just the first record by doing a subquery and SELECT TOP 1 ... ORDER BY someField, or you need to use an aggregate function like MAX, MIN, AVG, etc.

I cannot do aggregate functions (in this case) because I am modifying existing code. And I cannot use TOP 1 either. I think there is a way to add a (Select Fld1 from Table2 where...) Fld2add to make it work. But I am not sure about the syntax.
Thank you for your help.
"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