Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Finding data in table
Message
 
 
À
17/03/2003 14:53:16
Billy Bramhall
Interdirect Usa, Inc.
Houston, Texas, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00766682
Message ID:
00766698
Vues:
30
>I would like to find (and print) the last record in a table that has specific data.
>
>Example: a table consisting of 300 records, record numbers 3, 41 & 250 has the field (field.computer) populated with the name "hellcat". I would like to find/print record number 250. (The tricky part of course is, I do not know that recno()=250 has the data I need.)
>
>Any help on the proper syntax is greatly appreciated.
>
>Thanks,
>Billy
Select Top 1 * ;
	From SourceTable ;
	Into Cursor curToPrint ;
	Where SourceTable.Computer = "hellcat" ;
	Order By Computer Desc
Since (in your example above) all three resulting rows have the value "hellcat" it may be that the DESC clause will not reverse the record order. If this is the case then you might be able to use:
Select Top 1 *, RecNo() as Rec_No ;
	From SourceTable ;
	Into Cursor curToPrint ;
	Where SourceTable.Computer = "hellcat" ;
	Order By Rec_No Desc
PS. Some people will frown upon the use of RecNo() in SQL statements because the current work area / alias automatically changes during the SELECT. This is because VFP does something similar to a USE AGAIN (in a different data session). However since only one table is involved there should not be a problem.
censored.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform