Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL selecting duplicate records
Message
From
02/03/1998 11:39:16
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
02/03/1998 11:18:01
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00082085
Message ID:
00082100
Views:
23
>>I need help writing the sql to return all the duplicate records in a table. The key fields are author and title and I need all the duplicates returned. If there is a duplicate record I need to see both. Any help would be appreciated.
>
>
>select recno() as rcno from myTable ;
>   where .t. ;
>   having cnt(*) = 1 ;
>   group by author, title ;
>   into cursor noDup
>use dbf("noDup") in 0 again alias noDuplicate
>use in "noDup"
>select noDuplicate
>index on rcno tag rcno
>select myTable
>browse for !seek(recno(),"noDuplicate","rcno")
>
>Also there is a utility in files section called "dupcheck.zip"
>Cetin
Correction to above code (recno() would fail with group).
select author, title from myTable ;
   where .t. ;
   having cnt(*) = 1 ;
   group by author, title ;
   into cursor noDup
use dbf("noDup") in 0 again alias noDuplicate
use in "noDup"
select noDuplicate
index on author+title tag main
select myTable1
browse for !seek(author+title,"noDuplicate","main")

* Or if dups are less
select author, title from myTable ;
   where .t. ;
   having cnt(*) > 1 ;
   group by author, title ;
   into cursor Dups
use dbf("Dups") in 0 again alias Duplicate
use in "Dups"
select Duplicate
index on author+title tag main
select myTable1
browse for seek(author+title,"Duplicate","main")
cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform