Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Combining records from 2 tables
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00289396
Message ID:
00289400
Vues:
32
>Hello,
> I have 2 tables, both tables contain some fields. One table contains all the current transactions and the other holds all the old transactions. Can anyone tell me what is the best way to retrieve 5 latest transactions on a specific account ?? thanks

Are the tables identical in structure? If so, a UNION clause to join the results of both tables might be helpful.

Eg: two tables, oldrecs and newrecs, identical in structure:
SELECT 0
USE OldRecs
FOR nI = 1 TO FCOUNT()  && Get the transdate field number
   IF UPPER(FIELD(nI)) = "TRANSDATE"
      EXIT
   ENDIF
ENDFOR

SELECT TOP 5 * FROM OldRecs ;
  INTO CURSOR allRecs ;
 WHERE RecID = MyTargetKeyValue ;
UNION ALL ( ;
 SELECT * FROM NewRecs ;
   WHERE RecID = MyTargetKetValue ;
   ORDER BY nI )  && nI is set above
*
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform