Re: Insert non duplicate data
- From: <nickname@xxxxxxxxxxxxx>
- Date: Sat, 25 Jun 2005 20:53:34 +0100
INSERT INTO test (X,Y)
SELECT '1','2'
WHERE NOT EXISTS(SELECT 1 FROM test WHERE X='1' AND Y='2')
"Leo" <Leo@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:1736A83A-FA81-46CA-A95A-4D0582E28BFC@xxxxxxxxxxxxxxxx
> I'm trying to construct an insert statement which will only insert data if
> it
> hasn't been inserted before in the same table, i.e. insert x,y into table
> where not exists (select x,y from table), or some such statement. Is there
> an
> easy way of doing this - maybe an if statement that selects x,y and if
> they
> don't exist they are inserted? What would the syntax of such a query be?
.
- References:
- Insert non duplicate data
- From: Leo
- Insert non duplicate data
- Prev by Date: Help with Query
- Next by Date: Re: SQL and Grouping
- Previous by thread: Insert non duplicate data
- Next by thread: Return Part of a text field
- Index(es):