Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
USE table without structural index
Message
De
15/04/2010 12:51:53
Mike Yearwood
Toronto, Ontario, Canada
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01459949
Message ID:
01460336
Vues:
54
>Yes, but I was trying to get to the duplicate pk records and flag them in a different field, without disturbing the now corrupted index, and then go on with the processing.
>
>
>As a related question, can you tell me why
>
>select key from mytable group by 1 having count(*) > 1
>
>returns no records, and
>
>select key from mytable having count(*) > 1
>
>retuns the last record?
>
>Thanks,
>
>Al Allison
>

You cannot even do this query in VFP9 unless you SET ENGINEBEHAVIOR 70. This is one of the reasons one should stick to SQL standards IMO. You have to know what you're asking for.

Aside from the fact that computers are so dumb that they will do whatever we tell them, I can only explain how I think SQL works. :)

Count(*) is supposed to start counting on each group. In this case there is no group, so it counts all the way to the end of the table, resulting in a count(*) of the number of records in the table which is certainly >1. The having takes place after returning the set of records indicated by select key from mytable. So VFP is physically sitting on the last record when the having count(*)>1 condition evaluates to .T. and so you get the last record.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform