This is certainly the first step.

Also, if you want to "insert only those rows which are not already present",
you can use something akin to:

INSERT INTO table1
SELECT * FROM table2 t2
LEFT JOIN table1 t1 ON (unique row identifiers -- whatever these are for
your data)
WHERE t1.XYZ IS NULL


(obviously put in the appropriate column names etc for your data structure!)


Cheers,

Matt

> -----Original Message-----
> From: Joshua J. Kugler [mailto:[EMAIL PROTECTED]
> Sent: 07 July 2004 22:22
> To: [EMAIL PROTECTED]
> Subject: Re: INSERT DISTINCT?
> 
> Certainly, it's called making a unique index on the field(s) you want to
> keep
> unique.
> 
> Hope that helps.
> 
> j----- k-----
> 
> On Wednesday 07 July 2004 12:48 pm, John Mistler said something like:
> > Is there a way to do an INSERT on a table only if no row already exists
> > with the same info for one or more of the columns as the row to be
> > inserted? That is, without using a method outside SQL?
> >
> > Thanks,
> >
> > John
> 
> --
> Joshua J. Kugler -- Fairbanks, Alaska -- ICQ#:13706295
> Every knee shall bow, and every tongue confess, in heaven, on earth, and
> under
> the earth, that Jesus Christ is LORD -- Count on it!
> 
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]




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

Reply via email to