Pankaj <panahuja@gmail.com> wrote:
> On Feb 6, 3:42 am, p...@RQNNE.invalid (Per Rønne) wrote:
> > Pankaj <panah...@gmail.com> wrote:
> > > I am using this query to find duplicate records (first_name, last_name
> > > and i_active).
> >
> > Make sure to use a primary key. In this way duplicate records will never
> > occur.
> I am using primary keys. but some fields like first_name and last_name
> can be duplicate :-)
Yes, but if you use primary keys, /per definition/ no duplicate records
can exist.
But of course, in a person database with let's say one milliard records,
there may be more than one male holding the name John Smith :-).
In your country you may not have a Central Person Register number
uniquely defining every citizen and metic, and for other reasons it may
not be wise to use such a field as the primary key. Then just define one
column or a set of columns as being 'unique'.
Perhaps I should add that I'm more used to Oracle than to MySQL.
--
Per Erik Rønne
http://www.RQNNE.dk