On Feb 4, 2008 7:17 PM, Baron Schwartz <[EMAIL PROTECTED]> wrote:
> On Feb 4, 2008 11:36 AM, Artifex Maximus <[EMAIL PROTECTED]> wrote:
> > Hello!
> >
> > I am looking for an easy solution for eliminate duplicates but on a row 
> > level.
> >
> > I am having 2 tables. 1 destination for all not duplicated info (a)
> > and 1 for input table (b) which might have duplicates related to table
> > a. Now I am using this kind of insert:
> >
> > INSERT INTO a
> > SELECT fields
> > FROM b
> > WHERE ... NOT EXISTS (
> > SELECT * FROM a WHERE (a.a,a.b,a.c,a.d)=(b.a,b.b,b.c,b.d)
> > )
> >
> > Looks like it works but is it any solution for row level compare
> > without naming all fields? For example WHERE (a.*) = (b.*) instead of
> > currently used (a.a,a.b,...)=(b.a,b.b,...).
>
> You could use this:
>
> INSERT .. SELECT .. FROM b
> NATURAL LEFT OUTER JOIN a
> WHERE a.primary_key_column IS NULL
Thank you very much! Sounds good and I read mysql documentation (it is
easier because I know now what I am look for...).

Unfortunately I do not have primary_key_column. I am trying to merge
phone call logs from six different machines to make a master call log.
Individual logs have unique id field, which might use as primary key
but unique id is unique only on one machine and other machine may have
the same unique id (as it actually happens). So it is only unique
within database but not within machines. There is a big mess around
and call logs might shared between machines means that only record
that contains same values for all fields is unique. Because it is an
automatic call-out campaign log I have to include some extra
information in master log. Is it problem for 'natural join' that any
side have extra fields? I read in the documentation that natural join
must have the same fields on both table but I got no error on missing
fields now. Is it compare automatically only fields that have the same
name?

bye,
a

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to