> When i do a insert is there a way to know row already exists!!
Not without querying.
But you could do something like this:
CREATE TABLE t1(a PRIMARY KEY, b, c);
insert into t1
select 7, 'foo', 'bar' where not exists (
select null from t1 where a=7);
which is similar to:
You can put a Primary Key (unique index) on the table.
Then when inserting a duplicate, an error will be generated.
Then test for the error.
Or if you want the new row to overwrite the original use insert or replace
If you goal is to keep the existing use insert or ignore.
see:
--Original Message-
From: RaghavendraK 70574 [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 19, 2007 8:00 AM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] Duplicate Row check
Q was incomplete.
When i do a insert is there a way to know row already exists!!
reg
On 7/19/07, RaghavendraK 70574 <[EMAIL PROTECTED]> wrote:
Q was incomplete.
When i do a insert is there a way to know row already exists!!
what is the definition of "row already exists"? If you are concerned
about a particular column, make that into a PK. If you are concerned
about all the
> How can check if a row exists in the db or not without querying for it?
Isn't the very act of asking whether it exists a query unto itself?
Looking for a deal? Find great prices on flights and hotels
Q was incomplete.
When i do a insert is there a way to know row already exists!!
regrads
ragha
**
This email and its attachments contain confidential information from HUAWEI,
which is intended only for the
6 matches
Mail list logo