primary keys from distinct rows
Posted in 1999
Topics: SQL Development & Query Writing
I am working with an Informix Database and want to isolate just the entry id fields, the primary key, of the distinct entries in 4 other fields in the same table. Basically, I want to eliminate the duplicates but I cannot do this with the primary key as it is unique to each entry. I am testing the other fields for matches and placing their primary key into a temp table to check against the permanent table and eliminate the duplicates. I have not been able to isolate the user ids that are associated with each entry when I do this query. I have done a select distinct across the 4 fields but not the primary key and that returns the 4 fields in the temp table but does not include the primary key. When I do include the primary key in the select statement it returns every record since every primary key is distinct. I also tried a subquery but I cannot seem to run a distinct query as part of a subquery within the original query for the primary key. So if I say "select <primary key> from <table> where (<select distinct field>;" it does not work for me. Can anyone help -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own