Hi,

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

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

Reply via email to