Re: Check For Uniqueness

From: DriftWood <drift_wood_at_my-deja.com>
Date: Tue, 07 Mar 2000 19:08:20 GMT
Message-ID: <8a3k30$3c3$1_at_nnrp1.deja.com>


Here is some simple SQL that can be used to check duplicates -- it would be easy to modify this to see if a record is unique.

To check for single column duplicates (deptno only):

  select rowid, deptno
  from dept outer
  where
  outer.rowid >
  (select min(rowid) from dept inner
  where inner.deptno=outer.deptno)
  order by deptno;

To check for multi-column (key) duplicates (deptno and dname):

  select rowid, deptno, dname
  from dept outer
  where
  outer.rowid >
  (select min(rowid) from dept inner
  where inner.deptno||inner.dname=outer.deptno||outer.deptno)   order by deptno;
>

--
-cheers
  DW
--------------------------------------------------------------------
"It is a kind of good deed to say well; and yet words are not deeds.
  -William Shakespeare"


Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Tue Mar 07 2000 - 20:08:20 CET

Original text of this message