Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Eliminating duplicates with related SQL statement
Message
From
07/05/2002 07:06:20
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
07/05/2002 05:00:00
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00653393
Message ID:
00653409
Views:
20
>I create a cursor, joining two tables like this:
>
>SELECT * FROM ChildTable LEFT JOIN ParentTable;
> ON ChildTable.Key = ParentTable.Key
>
>It works fine, but I want to eliminate possible duplicate records (with the same key fields) in a ParentTable, because in that case it would be all child records duplicated in a result cursor too.
>It's not possible to organize a primary index with no duplicates in a ParentTable, I need just this cursor to be made with this logic.
>
>
>So, it could be done when I make another cursor from ParentTable:
>
>SELECT * FROM ParentTable group by ParentTable.Key:
> into cursor ParentWithoutDuplicates
>
>and join the ChildTable with the new cursor.
>
>But I don't like this way; ParentTable could have large number of records, etc.
>
>Is it a simple way to join two tables and prevent duplicates (as it was in FoxPro 2.6)?
>
>Thank's, Zlatko.

Anything that worked in FoxPro 2.6 should still work in VFP.

Apart from GROUP BY, you can also use the DISTINCT clause.

Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform