Where Not Exists

Where Not Exists

am 23.11.2005 15:56:16 von Chris Thompson

This is a multi-part message in MIME format.

------=_NextPart_000_004E_01C5F03E.0DE7F0B0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi All,

I'm trying to work out how to change the following mysql statement which =
inserts rows from one table into another. I want to ensure that it does =
*not* insert rows if an exact match of the row already exists on the =
table.

I've tried to use WHILE NOT EXISTS, but I can't seem to get the syntax =
right... can anyone help please?

INSERT INTO Contacts SELECT DISTINCT null as =
ID,CustName,Company,TelNo,Email,Mobile,Web,Address FROM ConTemp

(It works as is, but causes duplicate rows).

Thanks in advance of any assistance...,

Chris.



------=_NextPart_000_004E_01C5F03E.0DE7F0B0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable



charset=3Diso-8859-1">




Hi All,

 

I'm trying to work out how to change =
the following=20
mysql statement which inserts rows from one table into another.  I =
want=20
to ensure that it does *not* insert rows if an exact match of the =
row=20
already exists on the table.

 

I've tried to use WHILE NOT EXISTS, but =
I can't=20
seem to get the syntax right... can anyone help please?

 


INSERT INTO Contacts SELECT DISTINCT null =
as=20
ID,CustName,Company,TelNo,Email,Mobile,Web,Address FROM =
ConTemp


(It works as is, but causes duplicate=20
rows).


Thanks in advance of any =
assistance...,


Chris.


 



------=_NextPart_000_004E_01C5F03E.0DE7F0B0--

Re: Where Not Exists

am 23.11.2005 17:09:24 von Stefan Rybacki

Chris Thompson wrote:
> Hi All,
>
> I'm trying to work out how to change the following mysql statement which
> inserts rows from one table into another. I want to ensure that it does
> *not* insert rows if an exact match of the row already exists on the table.
>
> I've tried to use WHILE NOT EXISTS, but I can't seem to get the syntax
> right... can anyone help please?
>
>
> INSERT INTO Contacts SELECT DISTINCT null as
> ID,CustName,Company,TelNo,Email,Mobile,Web,Address FROM ConTemp
>
> (It works as is, but causes duplicate rows).

Create an unique index over
CustName,Company,TelNo,Email,Mobile,Web,Address

Regards
Stefan

>
> Thanks in advance of any assistance...,
>
> Chris.
>
>
>