Subject Re: [firebird-support] Re: duplicate string fields?
Author Woody
Svein Erling Tysvær wrote:
> If there is any chance of triplicates, not only duplicates, then the above statement would return too many rows and you would be better off doing:
>
That's why I suggested the exists query previously. If you know there
are duplicates, why couldn't there be more than 2 of the same string? No
single record can contain the information from a single query in that
case, without writing a procedure. The only way to do this is to list
each one (record) separately by their id's along with the duplicated
string. It's a simple matter to delete duplicates that way but not so
easy to list them.

> select a.noteid, a.folderid, a.subject
> from dbnotes a
> where exists(select *
> from dbnotes b where a.subject = b.subject
> and NOT (a.noteid = b.noteid))

Does the "NOT (a.noteid = b.noteid)" convert to "(a.noteid <> b.noteid)"
within FB or is it treated differently? I'm asking because I don't know
but would be interested in finding out because if it's faster, I might
start using that syntax instead.

Oh yeah, I would change the "select *" to "select 1", too. Mainly
because ^heLen has, er, forcibly reiterated her desire to shoot anyone
who uses select *. :-)

Woody (TMW)