Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show repeated values in a table field

Status
Not open for further replies.

SitesMasstec

Programmer
Sep 26, 2010
526
Brasil
Dear colleagues:

My table FRIENDS has a numeric field defined as CODFRI, which is the primary key.

How do I get all repeated codes in the field CODFRI? I imported data from an old file, and I got records:

CODFRI: NAMEFRI
133 John
133 Mary
134 Sebastian
135 Charles
etc

I tried LIST NOT DISTINCT CODFRI and others commands with no results, just errors.

Thank you,
SitesMasstec
 
Code:
How do I get all repeated codes in the field CODFRI?

Code:
Select Codfri, Count(*) As Howmany ;
  from Namer ;
 Group by CodFri ;
Having Howmany > 1 ;
  Into Cursor MyDuplicates

But I suspect you're really looking for something else.
 
You're lying! [bigsmile]

No, don't think of this as accusation, but you're missing something. If your field CODFRI really would be primary key, with a primary index on it, then it won't allow double values. If you already use it as primary key, eg as foreign key in other tables, without having the primary index on it, you asked for this trouble.

Dan gave you code to find double values.

When you make a field a real primary key field, you have to check for double values before inserting or appending data. Data with already existing IDs either should be updates or is an error. That may be decided by other parts of the record, but is a totally different topic.

You technically prevent double values in a field (or an expression on two or three fields) via a primary index. In free tables you don't have that index type, but the candidate index has the equivalent characteristics.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top