Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP60- Dabatases and Tables
Message
From
28/12/1999 14:18:11
 
 
To
28/12/1999 10:38:41
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00308802
Message ID:
00309349
Views:
36
I don't have any books, SQL is just something I leanred from doing it (and some from school). I'm sure you could find a bunch of bookds by searching SQL at amazon.com.

>Just wanted to thank you for your help and ask you if you know of some books/literature/web sites where I can learn more about SELECT - SQL commands.
>
>
>>Ok, either I misunderstood what you were trying to do, or you misunderstood the purpose of the example I gave you. The COUNT(*), and the HAVING clause fill the result cursor with only records that have duplicates. A duplicate, by definition is a record that shares a set of values with at least one other record. The COUNT() field tells you how many records share the attributes, and the having clause eliminates records with no duplicates.
>>
>>The trick is, the result set doesn't show EACH duplicate record, but a grouped aggregate of all of the records fitting the description. If you want to actually select all records that are duplicates, you have to use the results of the first query and join them to the second using the GROUP BY criteria in the join:
>>
>>SELECT COUNT(*), * FROM MyTable GROUP BY Field1, Field2 INTO CURSOR Dupes
>>
>>SELECT MyTable.* ;
>>FROM MyTable, Dupes ;
>>WHERE MyTable.Field1 = Dupes.Field1 ;
>>AND MyTable.Field2 = Dupes.Field2 ;
>>INTO CURSOR AllDupes
>>
>>The second result set will contain a copy of EVERY record that has a duplicate. Not ONE of the duplicates, but all of them, which means if you are trying to eliminate dupes, one of these records is a good one, and one is the throwaway.
>>
>>
>>>QUESTION #1:
>>>I have been playing with the SELECT command you showed me and I don't understand why the COUNT(*) and the HAVING clause are needed in it. I get the same results (unique records) if I do the following two commands:
Erik Moore
Clientelligence
Previous
Reply
Map
View

Click here to load this message in the networking platform