Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is MAX() a good choice where GROUP BY?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01676115
Message ID:
01676130
Vues:
66
This message has been marked as the solution to the initial question of the thread.
>>Here is an example:
*-- Table1
*-- Strucutre:
FIELD1     FIELDX    FIELDY
2
4
2
2
1
4
4

*-- Table 2
*-- Structure
FIELD1     FIELD2    FIELD3
1               'ABC'      '123'
2               'XYZ'      '456'
3              'DFD'      '333'
4              'DDF'      '444'

*-- Resulting query should be
FIELD1     FIELD2     FIELD3
1               'ABC'      '123'
2               'XYZ'      '456'
4              'DDF'      '444'
>>
>>Now that I wrote the example, above, I think I can SELECT from Table2 and JOIN Table1 on FIELD1.


I think you do not even need a join for this, you can just select the records from Table2 that have a FK in Table 1, like:
SELECT Field1, Field2, Field3 FROM Table2 WHERE Field1 IN (SELECT Field1 FROM Table1)
As you are not using the FieldX and FieldY at all
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform